@webiny/project 6.0.0 → 6.1.0-beta.0
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/abstractions/features/DeployApp.d.ts +0 -1
- package/abstractions/features/DeployApp.js.map +1 -1
- package/abstractions/features/pulumi/AdminPulumi.d.ts +3 -0
- package/abstractions/features/pulumi/AdminPulumi.js +3 -0
- package/abstractions/features/pulumi/AdminPulumi.js.map +1 -1
- package/abstractions/features/pulumi/ApiPulumi.d.ts +3 -0
- package/abstractions/features/pulumi/ApiPulumi.js +3 -0
- package/abstractions/features/pulumi/ApiPulumi.js.map +1 -1
- package/abstractions/features/pulumi/CorePulumi.d.ts +3 -0
- package/abstractions/features/pulumi/CorePulumi.js +3 -0
- package/abstractions/features/pulumi/CorePulumi.js.map +1 -1
- package/defineExtension/models/ExtensionDefinitionModel.d.ts +4 -4
- package/defineExtension/models/ExtensionDefinitionModel.js.map +1 -1
- package/defineExtension/models/ExtensionInstanceModel.js +1 -1
- package/defineExtension/models/ExtensionInstanceModel.js.map +1 -1
- package/defineExtension/zodTypes/zodSrcPath.d.ts +1 -1
- package/exports/infra.d.ts +8 -0
- package/exports/infra.js +10 -0
- package/exports/{infra/index.js.map → infra.js.map} +1 -1
- package/extensions/AdminBuildParam.d.ts +2 -8
- package/extensions/AdminBuildParam.js +1 -1
- package/extensions/AdminBuildParam.js.map +1 -1
- package/extensions/AdminExtension.d.ts +2 -8
- package/extensions/ApiBuildParam.d.ts +2 -8
- package/extensions/ApiBuildParam.js +1 -1
- package/extensions/ApiBuildParam.js.map +1 -1
- package/extensions/ApiExtension.d.ts +2 -8
- package/extensions/DatabaseSetup.d.ts +6 -6
- package/extensions/EnvVar.d.ts +4 -7
- package/extensions/EnvVar.js +4 -0
- package/extensions/EnvVar.js.map +1 -1
- package/extensions/ExtensionDefinitions.d.ts +1 -5
- package/extensions/FeatureFlags.d.ts +5 -79
- package/extensions/ProjectDecorator.d.ts +2 -6
- package/extensions/ProjectId.d.ts +2 -6
- package/extensions/ProjectImplementation.d.ts +2 -8
- package/extensions/Telemetry.d.ts +1 -5
- package/extensions/hooks/AdminAfterBuild.d.ts +2 -6
- package/extensions/hooks/AdminAfterDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeBuild.d.ts +2 -6
- package/extensions/hooks/AdminBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeWatch.d.ts +2 -6
- package/extensions/hooks/AfterBuild.d.ts +2 -6
- package/extensions/hooks/AfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiAfterBuild.d.ts +2 -6
- package/extensions/hooks/ApiAfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeBuild.d.ts +2 -6
- package/extensions/hooks/ApiBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeWatch.d.ts +2 -6
- package/extensions/hooks/BeforeBuild.d.ts +2 -6
- package/extensions/hooks/BeforeDeploy.d.ts +2 -6
- package/extensions/hooks/BeforeWatch.d.ts +2 -6
- package/extensions/hooks/CoreAfterBuild.d.ts +2 -6
- package/extensions/hooks/CoreAfterDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeBuild.d.ts +2 -6
- package/extensions/hooks/CoreBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeWatch.d.ts +2 -6
- package/extensions/index.d.ts +24 -140
- package/extensions/infra/Ci.d.ts +14 -0
- package/extensions/infra/Ci.js +29 -0
- package/extensions/infra/Ci.js.map +1 -0
- package/extensions/infra/index.d.ts +1 -0
- package/extensions/infra/index.js +1 -0
- package/extensions/infra/index.js.map +1 -1
- package/extensions/pulumi/AdminPulumi.d.ts +2 -6
- package/extensions/pulumi/AdminStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ApiPulumi.d.ts +2 -6
- package/extensions/pulumi/ApiStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/CorePulumi.d.ts +2 -6
- package/extensions/pulumi/CoreStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ProductionEnvironments.d.ts +2 -6
- package/extensions/pulumi/PulumiResourceNamePrefix.d.ts +1 -5
- package/features/BuildApp/PackagesBuilder/worker.js +1 -1
- package/features/BuildApp/PackagesBuilder/worker.js.map +1 -1
- package/features/GetFeatureFlags/GetFeatureFlags.d.ts +1 -2
- package/features/GetFeatureFlags/GetFeatureFlags.js +1 -2
- package/features/GetFeatureFlags/GetFeatureFlags.js.map +1 -1
- package/features/Watch/localInvocationWorker.js +5 -1
- package/features/Watch/localInvocationWorker.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +27 -26
- package/services/GetProjectConfigService/GetProjectConfigService.js +2 -1
- package/services/GetProjectConfigService/GetProjectConfigService.js.map +1 -1
- package/services/GetProjectConfigService/renderConfigWorker.js +12 -3
- package/services/GetProjectConfigService/renderConfigWorker.js.map +1 -1
- package/services/GetProjectService/GetProjectService.js +2 -2
- package/services/GetProjectService/GetProjectService.js.map +1 -1
- package/services/GetProjectVersionService/GetProjectVersionService.js +2 -2
- package/services/GetProjectVersionService/GetProjectVersionService.js.map +1 -1
- package/services/InstallExtensionService/types.d.ts +4 -0
- package/services/InstallExtensionService/types.js.map +1 -1
- package/services/InstallExtensionService/updateWebinyConfig.js +74 -47
- package/services/InstallExtensionService/updateWebinyConfig.js.map +1 -1
- package/utils/ExtensionSrcResolver.js +2 -1
- package/utils/ExtensionSrcResolver.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/index.js.map +1 -1
- package/utils/requireConfig.js +9 -5
- package/utils/requireConfig.js.map +1 -1
- package/utils/toImportSpecifier.d.ts +5 -0
- package/utils/toImportSpecifier.js +12 -0
- package/utils/toImportSpecifier.js.map +1 -0
- package/exports/infra/index.d.ts +0 -8
- package/exports/infra/index.js +0 -10
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.d.ts +0 -18
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js +0 -15
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js.map +0 -1
- package/features/Watch/watchers/utils/requireConfig.d.ts +0 -18
- package/features/Watch/watchers/utils/requireConfig.js +0 -15
- package/features/Watch/watchers/utils/requireConfig.js.map +0 -1
|
@@ -10,27 +10,27 @@ import fs from "fs";
|
|
|
10
10
|
const serializePropsToJsx = props => {
|
|
11
11
|
const attributes = [];
|
|
12
12
|
for (const [key, value] of Object.entries(props)) {
|
|
13
|
-
// Skip undefined values
|
|
13
|
+
// Skip undefined values.
|
|
14
14
|
if (value === undefined) {
|
|
15
15
|
continue;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// Determine the serialization based on value type
|
|
18
|
+
// Determine the serialization based on value type.
|
|
19
19
|
let serializedValue;
|
|
20
20
|
if (typeof value === "string") {
|
|
21
|
-
// Strings: use JSON.stringify to handle escaping, then wrap in curly braces
|
|
21
|
+
// Strings: use JSON.stringify to handle escaping, then wrap in curly braces.
|
|
22
22
|
serializedValue = `{${JSON.stringify(value)}}`;
|
|
23
23
|
} else if (typeof value === "number" || typeof value === "boolean") {
|
|
24
|
-
// Numbers and booleans: wrap in curly braces without quotes
|
|
24
|
+
// Numbers and booleans: wrap in curly braces without quotes.
|
|
25
25
|
serializedValue = `{${value}}`;
|
|
26
26
|
} else if (value === null) {
|
|
27
|
-
// Null values
|
|
27
|
+
// Null values.
|
|
28
28
|
serializedValue = `{null}`;
|
|
29
29
|
} else if (Array.isArray(value) || typeof value === "object") {
|
|
30
|
-
// Arrays and objects: use JSON.stringify, then wrap in curly braces
|
|
30
|
+
// Arrays and objects: use JSON.stringify, then wrap in curly braces.
|
|
31
31
|
serializedValue = `{${JSON.stringify(value)}}`;
|
|
32
32
|
} else {
|
|
33
|
-
// Fallback for any other types
|
|
33
|
+
// Fallback for any other types.
|
|
34
34
|
serializedValue = `{${JSON.stringify(value)}}`;
|
|
35
35
|
}
|
|
36
36
|
attributes.push(`${key}=${serializedValue}`);
|
|
@@ -38,6 +38,48 @@ const serializePropsToJsx = props => {
|
|
|
38
38
|
return attributes.join(" ");
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Adds a component to the Extensions function in the webiny.config.tsx content.
|
|
43
|
+
*/
|
|
44
|
+
const addComponentToExtensions = (content, componentName, props) => {
|
|
45
|
+
// Serialize props to JSX attributes.
|
|
46
|
+
const propsString = props ? serializePropsToJsx(props) : "";
|
|
47
|
+
|
|
48
|
+
// Generate component tag with or without props.
|
|
49
|
+
const componentTag = propsString ? `<${componentName} ${propsString} />` : `<${componentName} />`;
|
|
50
|
+
|
|
51
|
+
// Check if component already exists.
|
|
52
|
+
if (content.includes(componentTag)) {
|
|
53
|
+
return content;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Find the Extensions function's return statement and add component before the final </>.
|
|
57
|
+
// Strategy: Find "export const Extensions" block, then find the last </> and insert before it.
|
|
58
|
+
const extensionsFuncRegex = /export const Extensions = \(\) => \{[\s\S]*?\};/;
|
|
59
|
+
const extensionsFuncMatch = content.match(extensionsFuncRegex);
|
|
60
|
+
if (!extensionsFuncMatch) {
|
|
61
|
+
return content;
|
|
62
|
+
}
|
|
63
|
+
const funcContent = extensionsFuncMatch[0];
|
|
64
|
+
// Find all </> in the function - the last one closes the return statement.
|
|
65
|
+
const closingTags = [...funcContent.matchAll(/<\/>/g)];
|
|
66
|
+
if (closingTags.length === 0) {
|
|
67
|
+
return content;
|
|
68
|
+
}
|
|
69
|
+
const lastClosingTag = closingTags[closingTags.length - 1];
|
|
70
|
+
const lastClosingTagIndex = lastClosingTag.index;
|
|
71
|
+
|
|
72
|
+
// Find the indentation of the line containing the last </>.
|
|
73
|
+
const beforeClosing = funcContent.substring(0, lastClosingTagIndex);
|
|
74
|
+
const lines = beforeClosing.split("\n");
|
|
75
|
+
const lastLine = lines[lines.length - 1];
|
|
76
|
+
const indent = lastLine.match(/^(\s*)/)?.[1] || " ";
|
|
77
|
+
|
|
78
|
+
// Insert the component before the last </>.
|
|
79
|
+
const newFuncContent = funcContent.substring(0, lastClosingTagIndex) + `${indent}${componentTag}\n${indent}` + funcContent.substring(lastClosingTagIndex);
|
|
80
|
+
return content.replace(extensionsFuncRegex, newFuncContent);
|
|
81
|
+
};
|
|
82
|
+
|
|
41
83
|
/**
|
|
42
84
|
* Update the webiny.config.tsx file to add extension imports and component.
|
|
43
85
|
*/
|
|
@@ -54,62 +96,47 @@ export const updateWebinyConfig = async params => {
|
|
|
54
96
|
// Add imports at the top (after existing imports)
|
|
55
97
|
if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {
|
|
56
98
|
for (const importStatement of webinyConfigTsx.imports) {
|
|
57
|
-
|
|
99
|
+
// Check if we need to add to an existing import from the same path.
|
|
100
|
+
const existingImportRegex = new RegExp(`import\\s+{([^}]+)}\\s+from\\s+["']${importStatement.path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["'];?`, "m");
|
|
101
|
+
const existingImportMatch = content.match(existingImportRegex);
|
|
102
|
+
if (existingImportMatch) {
|
|
103
|
+
// Import from this path exists, check if specifier is already imported.
|
|
104
|
+
const existingSpecifiers = existingImportMatch[1].split(",").map(s => s.trim());
|
|
105
|
+
if (!existingSpecifiers.includes(importStatement.specifier)) {
|
|
106
|
+
// Append the new specifier to the existing import.
|
|
107
|
+
const updatedSpecifiers = [...existingSpecifiers, importStatement.specifier].join(", ");
|
|
108
|
+
const updatedImportLine = `import { ${updatedSpecifiers} } from "${importStatement.path}";`;
|
|
109
|
+
content = content.replace(existingImportRegex, updatedImportLine);
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
// No existing import from this path, add a new import line.
|
|
113
|
+
const importLine = `import { ${importStatement.specifier} } from "${importStatement.path}";`;
|
|
58
114
|
|
|
59
|
-
|
|
60
|
-
if (!content.includes(importLine)) {
|
|
61
|
-
// Find the position after the last import or at the beginning
|
|
115
|
+
// Find the position after the last import or at the beginning.
|
|
62
116
|
const importRegex = /^import\s+.*?from\s+["'].*?["'];?\s*$/gm;
|
|
63
117
|
const matches = Array.from(content.matchAll(importRegex));
|
|
64
118
|
if (matches.length > 0) {
|
|
65
|
-
// Add after the last import
|
|
119
|
+
// Add after the last import.
|
|
66
120
|
const lastImport = matches[matches.length - 1];
|
|
67
121
|
const lastImportEnd = lastImport.index + lastImport[0].length;
|
|
68
122
|
content = content.slice(0, lastImportEnd) + "\n" + importLine + content.slice(lastImportEnd);
|
|
69
123
|
} else {
|
|
70
|
-
// No imports found, add at the beginning
|
|
124
|
+
// No imports found, add at the beginning.
|
|
71
125
|
content = importLine + "\n\n" + content;
|
|
72
126
|
}
|
|
73
127
|
}
|
|
74
128
|
}
|
|
75
129
|
}
|
|
76
130
|
|
|
77
|
-
// Add component to the Extensions function
|
|
131
|
+
// Add component to the Extensions function.
|
|
78
132
|
if (webinyConfigTsx.component) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// Serialize props to JSX attributes
|
|
83
|
-
const propsString = props ? serializePropsToJsx(props) : "";
|
|
84
|
-
|
|
85
|
-
// Generate component tag with or without props
|
|
86
|
-
const componentTag = propsString ? `<${componentName} ${propsString} />` : `<${componentName} />`;
|
|
87
|
-
|
|
88
|
-
// Check if component already exists
|
|
89
|
-
if (!content.includes(componentTag)) {
|
|
90
|
-
// Find the Extensions function's return statement and add component before the final </>
|
|
91
|
-
// Strategy: Find "export const Extensions" block, then find the last </> and insert before it
|
|
92
|
-
const extensionsFuncRegex = /export const Extensions = \(\) => \{[\s\S]*?\};/;
|
|
93
|
-
const extensionsFuncMatch = content.match(extensionsFuncRegex);
|
|
94
|
-
if (extensionsFuncMatch) {
|
|
95
|
-
const funcContent = extensionsFuncMatch[0];
|
|
96
|
-
// Find all </> in the function - the last one closes the return statement
|
|
97
|
-
const closingTags = [...funcContent.matchAll(/<\/>/g)];
|
|
98
|
-
if (closingTags.length > 0) {
|
|
99
|
-
const lastClosingTag = closingTags[closingTags.length - 1];
|
|
100
|
-
const lastClosingTagIndex = lastClosingTag.index;
|
|
101
|
-
|
|
102
|
-
// Find the indentation of the line containing the last </>
|
|
103
|
-
const beforeClosing = funcContent.substring(0, lastClosingTagIndex);
|
|
104
|
-
const lines = beforeClosing.split("\n");
|
|
105
|
-
const lastLine = lines[lines.length - 1];
|
|
106
|
-
const indent = lastLine.match(/^(\s*)/)?.[1] || " ";
|
|
133
|
+
content = addComponentToExtensions(content, webinyConfigTsx.component.name, webinyConfigTsx.component.props);
|
|
134
|
+
}
|
|
107
135
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
136
|
+
// Add multiple components to the Extensions function.
|
|
137
|
+
if (webinyConfigTsx.components && webinyConfigTsx.components.length > 0) {
|
|
138
|
+
for (const component of webinyConfigTsx.components) {
|
|
139
|
+
content = addComponentToExtensions(content, component.name, component.props);
|
|
113
140
|
}
|
|
114
141
|
}
|
|
115
142
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fs","serializePropsToJsx","props","attributes","key","value","Object","entries","undefined","serializedValue","JSON","stringify","Array","isArray","push","join","updateWebinyConfig","params","projectRoot","webinyConfigTsx","webinyConfigPath","content","readFileSync","imports","length","importStatement","importLine","specifier","path","includes","importRegex","matches","from","matchAll","lastImport","lastImportEnd","index","slice","component","componentName","name","propsString","componentTag","extensionsFuncRegex","extensionsFuncMatch","match","funcContent","closingTags","lastClosingTag","lastClosingTagIndex","beforeClosing","substring","lines","split","lastLine","indent","newFuncContent","replace","writeFileSync"],"sources":["updateWebinyConfig.ts"],"sourcesContent":["import fs from \"fs\";\nimport { ExtensionWebinyConfigTsx } from \"./types.js\";\n\ninterface UpdateWebinyConfigParams {\n projectRoot: string;\n webinyConfigTsx: ExtensionWebinyConfigTsx;\n}\n\n/**\n * Serializes a props object to JSX attribute syntax.\n * Examples:\n * - { secretKey: \"value\" } => 'secretKey={\"value\"}'\n * - { enabled: true } => 'enabled={true}'\n * - { count: 42 } => 'count={42}'\n * - { config: { key: \"value\" } } => 'config={{\"key\":\"value\"}}'\n */\nconst serializePropsToJsx = (props: Record<string, any>): string => {\n const attributes: string[] = [];\n\n for (const [key, value] of Object.entries(props)) {\n // Skip undefined values\n if (value === undefined) {\n continue;\n }\n\n // Determine the serialization based on value type\n let serializedValue: string;\n\n if (typeof value === \"string\") {\n // Strings: use JSON.stringify to handle escaping, then wrap in curly braces\n serializedValue = `{${JSON.stringify(value)}}`;\n } else if (typeof value === \"number\" || typeof value === \"boolean\") {\n // Numbers and booleans: wrap in curly braces without quotes\n serializedValue = `{${value}}`;\n } else if (value === null) {\n // Null values\n serializedValue = `{null}`;\n } else if (Array.isArray(value) || typeof value === \"object\") {\n // Arrays and objects: use JSON.stringify, then wrap in curly braces\n serializedValue = `{${JSON.stringify(value)}}`;\n } else {\n // Fallback for any other types\n serializedValue = `{${JSON.stringify(value)}}`;\n }\n\n attributes.push(`${key}=${serializedValue}`);\n }\n\n return attributes.join(\" \");\n};\n\n/**\n * Update the webiny.config.tsx file to add extension imports and component.\n */\nexport const updateWebinyConfig = async (params: UpdateWebinyConfigParams): Promise<void> => {\n const { projectRoot, webinyConfigTsx } = params;\n\n const webinyConfigPath = `${projectRoot}/webiny.config.tsx`;\n\n // Read the current webiny.config.tsx\n let content = fs.readFileSync(webinyConfigPath, \"utf-8\");\n\n // Add imports at the top (after existing imports)\n if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {\n for (const importStatement of webinyConfigTsx.imports) {\n const importLine = `import { ${importStatement.specifier} } from \"${importStatement.path}\";`;\n\n // Check if import already exists\n if (!content.includes(importLine)) {\n // Find the position after the last import or at the beginning\n const importRegex = /^import\\s+.*?from\\s+[\"'].*?[\"'];?\\s*$/gm;\n const matches = Array.from(content.matchAll(importRegex));\n\n if (matches.length > 0) {\n // Add after the last import\n const lastImport = matches[matches.length - 1];\n const lastImportEnd = lastImport.index! + lastImport[0].length;\n content =\n content.slice(0, lastImportEnd) +\n \"\\n\" +\n importLine +\n content.slice(lastImportEnd);\n } else {\n // No imports found, add at the beginning\n content = importLine + \"\\n\\n\" + content;\n }\n }\n }\n }\n\n // Add component to the Extensions function\n if (webinyConfigTsx.component) {\n const componentName = webinyConfigTsx.component.name;\n const props = webinyConfigTsx.component.props;\n\n // Serialize props to JSX attributes\n const propsString = props ? serializePropsToJsx(props) : \"\";\n\n // Generate component tag with or without props\n const componentTag = propsString\n ? `<${componentName} ${propsString} />`\n : `<${componentName} />`;\n\n // Check if component already exists\n if (!content.includes(componentTag)) {\n // Find the Extensions function's return statement and add component before the final </>\n // Strategy: Find \"export const Extensions\" block, then find the last </> and insert before it\n const extensionsFuncRegex = /export const Extensions = \\(\\) => \\{[\\s\\S]*?\\};/;\n const extensionsFuncMatch = content.match(extensionsFuncRegex);\n\n if (extensionsFuncMatch) {\n const funcContent = extensionsFuncMatch[0];\n // Find all </> in the function - the last one closes the return statement\n const closingTags = [...funcContent.matchAll(/<\\/>/g)];\n\n if (closingTags.length > 0) {\n const lastClosingTag = closingTags[closingTags.length - 1];\n const lastClosingTagIndex = lastClosingTag.index!;\n\n // Find the indentation of the line containing the last </>\n const beforeClosing = funcContent.substring(0, lastClosingTagIndex);\n const lines = beforeClosing.split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n const indent = lastLine.match(/^(\\s*)/)?.[1] || \" \";\n\n // Insert the component before the last </>\n const newFuncContent =\n funcContent.substring(0, lastClosingTagIndex) +\n `${indent}${componentTag}\\n${indent}` +\n funcContent.substring(lastClosingTagIndex);\n\n content = content.replace(extensionsFuncRegex, newFuncContent);\n }\n }\n }\n }\n\n // Write the updated content back\n fs.writeFileSync(webinyConfigPath, content, \"utf-8\");\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAQnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAIC,KAA0B,IAAa;EAChE,MAAMC,UAAoB,GAAG,EAAE;EAE/B,KAAK,MAAM,CAACC,GAAG,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ePropsToJsx","props","attributes","key","value","Object","entries","undefined","serializedValue","JSON","stringify","Array","isArray","push","join","addComponentToExtensions","content","componentName","propsString","componentTag","includes","extensionsFuncRegex","extensionsFuncMatch","match","funcContent","closingTags","matchAll","length","lastClosingTag","lastClosingTagIndex","index","beforeClosing","substring","lines","split","lastLine","indent","newFuncContent","replace","updateWebinyConfig","params","projectRoot","webinyConfigTsx","webinyConfigPath","readFileSync","imports","importStatement","existingImportRegex","RegExp","path","existingImportMatch","existingSpecifiers","map","s","trim","specifier","updatedSpecifiers","updatedImportLine","importLine","importRegex","matches","from","lastImport","lastImportEnd","slice","component","name","components","writeFileSync"],"sources":["updateWebinyConfig.ts"],"sourcesContent":["import fs from \"fs\";\nimport { ExtensionWebinyConfigTsx } from \"./types.js\";\n\ninterface UpdateWebinyConfigParams {\n projectRoot: string;\n webinyConfigTsx: ExtensionWebinyConfigTsx;\n}\n\n/**\n * Serializes a props object to JSX attribute syntax.\n * Examples:\n * - { secretKey: \"value\" } => 'secretKey={\"value\"}'\n * - { enabled: true } => 'enabled={true}'\n * - { count: 42 } => 'count={42}'\n * - { config: { key: \"value\" } } => 'config={{\"key\":\"value\"}}'\n */\nconst serializePropsToJsx = (props: Record<string, any>): string => {\n const attributes: string[] = [];\n\n for (const [key, value] of Object.entries(props)) {\n // Skip undefined values.\n if (value === undefined) {\n continue;\n }\n\n // Determine the serialization based on value type.\n let serializedValue: string;\n\n if (typeof value === \"string\") {\n // Strings: use JSON.stringify to handle escaping, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else if (typeof value === \"number\" || typeof value === \"boolean\") {\n // Numbers and booleans: wrap in curly braces without quotes.\n serializedValue = `{${value}}`;\n } else if (value === null) {\n // Null values.\n serializedValue = `{null}`;\n } else if (Array.isArray(value) || typeof value === \"object\") {\n // Arrays and objects: use JSON.stringify, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else {\n // Fallback for any other types.\n serializedValue = `{${JSON.stringify(value)}}`;\n }\n\n attributes.push(`${key}=${serializedValue}`);\n }\n\n return attributes.join(\" \");\n};\n\n/**\n * Adds a component to the Extensions function in the webiny.config.tsx content.\n */\nconst addComponentToExtensions = (\n content: string,\n componentName: string,\n props?: Record<string, any>\n): string => {\n // Serialize props to JSX attributes.\n const propsString = props ? serializePropsToJsx(props) : \"\";\n\n // Generate component tag with or without props.\n const componentTag = propsString\n ? `<${componentName} ${propsString} />`\n : `<${componentName} />`;\n\n // Check if component already exists.\n if (content.includes(componentTag)) {\n return content;\n }\n\n // Find the Extensions function's return statement and add component before the final </>.\n // Strategy: Find \"export const Extensions\" block, then find the last </> and insert before it.\n const extensionsFuncRegex = /export const Extensions = \\(\\) => \\{[\\s\\S]*?\\};/;\n const extensionsFuncMatch = content.match(extensionsFuncRegex);\n\n if (!extensionsFuncMatch) {\n return content;\n }\n\n const funcContent = extensionsFuncMatch[0];\n // Find all </> in the function - the last one closes the return statement.\n const closingTags = [...funcContent.matchAll(/<\\/>/g)];\n\n if (closingTags.length === 0) {\n return content;\n }\n\n const lastClosingTag = closingTags[closingTags.length - 1];\n const lastClosingTagIndex = lastClosingTag.index!;\n\n // Find the indentation of the line containing the last </>.\n const beforeClosing = funcContent.substring(0, lastClosingTagIndex);\n const lines = beforeClosing.split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n const indent = lastLine.match(/^(\\s*)/)?.[1] || \" \";\n\n // Insert the component before the last </>.\n const newFuncContent =\n funcContent.substring(0, lastClosingTagIndex) +\n `${indent}${componentTag}\\n${indent}` +\n funcContent.substring(lastClosingTagIndex);\n\n return content.replace(extensionsFuncRegex, newFuncContent);\n};\n\n/**\n * Update the webiny.config.tsx file to add extension imports and component.\n */\nexport const updateWebinyConfig = async (params: UpdateWebinyConfigParams): Promise<void> => {\n const { projectRoot, webinyConfigTsx } = params;\n\n const webinyConfigPath = `${projectRoot}/webiny.config.tsx`;\n\n // Read the current webiny.config.tsx\n let content = fs.readFileSync(webinyConfigPath, \"utf-8\");\n\n // Add imports at the top (after existing imports)\n if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {\n for (const importStatement of webinyConfigTsx.imports) {\n // Check if we need to add to an existing import from the same path.\n const existingImportRegex = new RegExp(\n `import\\\\s+{([^}]+)}\\\\s+from\\\\s+[\"']${importStatement.path.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"'];?`,\n \"m\"\n );\n const existingImportMatch = content.match(existingImportRegex);\n\n if (existingImportMatch) {\n // Import from this path exists, check if specifier is already imported.\n const existingSpecifiers = existingImportMatch[1].split(\",\").map(s => s.trim());\n\n if (!existingSpecifiers.includes(importStatement.specifier)) {\n // Append the new specifier to the existing import.\n const updatedSpecifiers = [\n ...existingSpecifiers,\n importStatement.specifier\n ].join(\", \");\n const updatedImportLine = `import { ${updatedSpecifiers} } from \"${importStatement.path}\";`;\n content = content.replace(existingImportRegex, updatedImportLine);\n }\n } else {\n // No existing import from this path, add a new import line.\n const importLine = `import { ${importStatement.specifier} } from \"${importStatement.path}\";`;\n\n // Find the position after the last import or at the beginning.\n const importRegex = /^import\\s+.*?from\\s+[\"'].*?[\"'];?\\s*$/gm;\n const matches = Array.from(content.matchAll(importRegex));\n\n if (matches.length > 0) {\n // Add after the last import.\n const lastImport = matches[matches.length - 1];\n const lastImportEnd = lastImport.index! + lastImport[0].length;\n content =\n content.slice(0, lastImportEnd) +\n \"\\n\" +\n importLine +\n content.slice(lastImportEnd);\n } else {\n // No imports found, add at the beginning.\n content = importLine + \"\\n\\n\" + content;\n }\n }\n }\n }\n\n // Add component to the Extensions function.\n if (webinyConfigTsx.component) {\n content = addComponentToExtensions(\n content,\n webinyConfigTsx.component.name,\n webinyConfigTsx.component.props\n );\n }\n\n // Add multiple components to the Extensions function.\n if (webinyConfigTsx.components && webinyConfigTsx.components.length > 0) {\n for (const component of webinyConfigTsx.components) {\n content = addComponentToExtensions(content, component.name, component.props);\n }\n }\n\n // Write the updated content back\n fs.writeFileSync(webinyConfigPath, content, \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EAEA;EACAF,EAAE,CAACqE,aAAa,CAACzB,gBAAgB,EAAE3B,OAAO,EAAE,OAAO,CAAC;AACxD,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { getTsconfig } from "get-tsconfig";
|
|
4
|
+
import { toImportSpecifier } from "./toImportSpecifier.js";
|
|
4
5
|
export class ExtensionSrcResolver {
|
|
5
6
|
static pathMappings = null;
|
|
6
7
|
|
|
@@ -14,7 +15,7 @@ export class ExtensionSrcResolver {
|
|
|
14
15
|
static async importFromPath(filePath, project) {
|
|
15
16
|
const importPath = this.resolvePath(filePath, project);
|
|
16
17
|
const exportName = path.basename(filePath).replace(path.extname(filePath), "");
|
|
17
|
-
const importedModule = await import(importPath);
|
|
18
|
+
const importedModule = await import(toImportSpecifier(importPath));
|
|
18
19
|
|
|
19
20
|
// Support both default and named exports.
|
|
20
21
|
// Check for 'default' property existence rather than truthiness.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["path","fs","getTsconfig","ExtensionSrcResolver","pathMappings","importFromPath","filePath","project","importPath","resolvePath","exportName","basename","replace","extname","importedModule","default","startsWith","paths","rootFolder","join","toString","resolved","resolvePathAlias","existsSync","absolutePath","projectRoot","loadPathMappings","pattern","targets","Object","entries","match","matchPattern","target","resolvedPath","replacePlaceholder","resolve","tsConfigPath","tsConfigFile","tsconfig","config","compilerOptions","endsWith","prefix","slice","length","mapping"],"sources":["ExtensionSrcResolver.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { getTsconfig } from \"get-tsconfig\";\nimport { type IProjectModel } from \"~/abstractions/models/index.js\";\n\nexport class ExtensionSrcResolver {\n private static pathMappings: { [key: string]: string[] } | null = null;\n\n /**\n * Import a module from a given file path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the default export or named export matching the filename.\n */\n static async importFromPath(filePath: string, project: IProjectModel) {\n const importPath = this.resolvePath(filePath, project);\n const exportName = path.basename(filePath).replace(path.extname(filePath), \"\");\n\n const importedModule = await import(importPath);\n\n // Support both default and named exports.\n // Check for 'default' property existence rather than truthiness.\n return (\n (\"default\" in importedModule && importedModule.default) || importedModule[exportName]\n );\n }\n\n /**\n * Resolve a file path to an absolute path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the absolute path without importing.\n */\n static resolvePath(filePath: string, project: IProjectModel): string {\n if (filePath.startsWith(\"/extensions/\")) {\n // Resolve from project root.\n return project.paths.rootFolder.join(filePath).toString();\n } else {\n // Try to resolve using tsconfig path aliases.\n const resolved = this.resolvePathAlias(filePath, project);\n if (resolved) {\n return resolved;\n } else {\n // Treat as absolute path.\n return filePath;\n }\n }\n }\n\n /**\n * Check if a file exists at the given path.\n * Resolves the path using the same logic as resolvePath before checking.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns true if the file exists, false otherwise.\n */\n static existsSync(filePath: string, project: IProjectModel): boolean {\n const absolutePath = this.resolvePath(filePath, project);\n return fs.existsSync(absolutePath);\n }\n\n private static resolvePathAlias(filePath: string, project: IProjectModel): string | null {\n const projectRoot = project.paths.rootFolder.toString();\n\n // Load path mappings from tsconfig if not already cached.\n if (this.pathMappings === null) {\n this.loadPathMappings(project);\n }\n\n if (!this.pathMappings) {\n return null;\n }\n\n // Try to match against each path pattern.\n for (const [pattern, targets] of Object.entries(this.pathMappings)) {\n const match = this.matchPattern(filePath, pattern);\n if (match !== null) {\n // Use the first mapping.\n const target = targets[0];\n const resolvedPath = this.replacePlaceholder(target, match);\n return path.resolve(projectRoot, resolvedPath);\n }\n }\n\n return null;\n }\n\n private static loadPathMappings(project: IProjectModel): void {\n const tsConfigPath = project.paths.tsConfigFile.toString();\n\n try {\n // Use get-tsconfig to parse tsconfig with extends resolution.\n const tsconfig = getTsconfig(tsConfigPath);\n\n if (tsconfig?.config.compilerOptions?.paths) {\n this.pathMappings = tsconfig.config.compilerOptions.paths;\n } else {\n this.pathMappings = {};\n }\n } catch {\n // Ignore tsconfig parsing errors.\n this.pathMappings = {};\n }\n }\n\n private static matchPattern(importPath: string, pattern: string): string | null {\n // Handle wildcard patterns like \"@/*\" or \"@extensions/*\".\n if (pattern.endsWith(\"/*\")) {\n const prefix = pattern.slice(0, -2);\n // Only match if there's a slash after the prefix.\n if (importPath.startsWith(prefix + \"/\")) {\n return importPath.slice(prefix.length + 1);\n }\n } else if (pattern === importPath) {\n return \"\";\n }\n\n return null;\n }\n\n private static replacePlaceholder(mapping: string, match: string): string {\n // Replace wildcard with the matched part.\n if (mapping.endsWith(\"/*\")) {\n return mapping.slice(0, -2) + \"/\" + match;\n }\n return mapping;\n }\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AACnB,SAASC,WAAW,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["path","fs","getTsconfig","toImportSpecifier","ExtensionSrcResolver","pathMappings","importFromPath","filePath","project","importPath","resolvePath","exportName","basename","replace","extname","importedModule","default","startsWith","paths","rootFolder","join","toString","resolved","resolvePathAlias","existsSync","absolutePath","projectRoot","loadPathMappings","pattern","targets","Object","entries","match","matchPattern","target","resolvedPath","replacePlaceholder","resolve","tsConfigPath","tsConfigFile","tsconfig","config","compilerOptions","endsWith","prefix","slice","length","mapping"],"sources":["ExtensionSrcResolver.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { getTsconfig } from \"get-tsconfig\";\nimport { toImportSpecifier } from \"./toImportSpecifier.js\";\nimport { type IProjectModel } from \"~/abstractions/models/index.js\";\n\nexport class ExtensionSrcResolver {\n private static pathMappings: { [key: string]: string[] } | null = null;\n\n /**\n * Import a module from a given file path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the default export or named export matching the filename.\n */\n static async importFromPath(filePath: string, project: IProjectModel) {\n const importPath = this.resolvePath(filePath, project);\n const exportName = path.basename(filePath).replace(path.extname(filePath), \"\");\n\n const importedModule = await import(toImportSpecifier(importPath));\n\n // Support both default and named exports.\n // Check for 'default' property existence rather than truthiness.\n return (\n (\"default\" in importedModule && importedModule.default) || importedModule[exportName]\n );\n }\n\n /**\n * Resolve a file path to an absolute path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the absolute path without importing.\n */\n static resolvePath(filePath: string, project: IProjectModel): string {\n if (filePath.startsWith(\"/extensions/\")) {\n // Resolve from project root.\n return project.paths.rootFolder.join(filePath).toString();\n } else {\n // Try to resolve using tsconfig path aliases.\n const resolved = this.resolvePathAlias(filePath, project);\n if (resolved) {\n return resolved;\n } else {\n // Treat as absolute path.\n return filePath;\n }\n }\n }\n\n /**\n * Check if a file exists at the given path.\n * Resolves the path using the same logic as resolvePath before checking.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns true if the file exists, false otherwise.\n */\n static existsSync(filePath: string, project: IProjectModel): boolean {\n const absolutePath = this.resolvePath(filePath, project);\n return fs.existsSync(absolutePath);\n }\n\n private static resolvePathAlias(filePath: string, project: IProjectModel): string | null {\n const projectRoot = project.paths.rootFolder.toString();\n\n // Load path mappings from tsconfig if not already cached.\n if (this.pathMappings === null) {\n this.loadPathMappings(project);\n }\n\n if (!this.pathMappings) {\n return null;\n }\n\n // Try to match against each path pattern.\n for (const [pattern, targets] of Object.entries(this.pathMappings)) {\n const match = this.matchPattern(filePath, pattern);\n if (match !== null) {\n // Use the first mapping.\n const target = targets[0];\n const resolvedPath = this.replacePlaceholder(target, match);\n return path.resolve(projectRoot, resolvedPath);\n }\n }\n\n return null;\n }\n\n private static loadPathMappings(project: IProjectModel): void {\n const tsConfigPath = project.paths.tsConfigFile.toString();\n\n try {\n // Use get-tsconfig to parse tsconfig with extends resolution.\n const tsconfig = getTsconfig(tsConfigPath);\n\n if (tsconfig?.config.compilerOptions?.paths) {\n this.pathMappings = tsconfig.config.compilerOptions.paths;\n } else {\n this.pathMappings = {};\n }\n } catch {\n // Ignore tsconfig parsing errors.\n this.pathMappings = {};\n }\n }\n\n private static matchPattern(importPath: string, pattern: string): string | null {\n // Handle wildcard patterns like \"@/*\" or \"@extensions/*\".\n if (pattern.endsWith(\"/*\")) {\n const prefix = pattern.slice(0, -2);\n // Only match if there's a slash after the prefix.\n if (importPath.startsWith(prefix + \"/\")) {\n return importPath.slice(prefix.length + 1);\n }\n } else if (pattern === importPath) {\n return \"\";\n }\n\n return null;\n }\n\n private static replacePlaceholder(mapping: string, match: string): string {\n // Replace wildcard with the matched part.\n if (mapping.endsWith(\"/*\")) {\n return mapping.slice(0, -2) + \"/\" + match;\n }\n return mapping;\n }\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AACnB,SAASC,WAAW,QAAQ,cAAc;AAC1C,SAASC,iBAAiB;AAG1B,OAAO,MAAMC,oBAAoB,CAAC;EAC9B,OAAeC,YAAY,GAAuC,IAAI;;EAEtE;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,aAAaC,cAAcA,CAACC,QAAgB,EAAEC,OAAsB,EAAE;IAClE,MAAMC,UAAU,GAAG,IAAI,CAACC,WAAW,CAACH,QAAQ,EAAEC,OAAO,CAAC;IACtD,MAAMG,UAAU,GAAGX,IAAI,CAACY,QAAQ,CAACL,QAAQ,CAAC,CAACM,OAAO,CAACb,IAAI,CAACc,OAA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GAAG,CAAC,EAAE;QACrC,OAAOnC,UAAU,CAACoC,KAAK,CAACD,MAAM,CAACE,MAAM,GAAG,CAAC,CAAC;MAC9C;IACJ,CAAC,MAAM,IAAIlB,OAAO,KAAKnB,UAAU,EAAE;MAC/B,OAAO,EAAE;IACb;IAEA,OAAO,IAAI;EACf;EAEA,OAAe2B,kBAAkBA,CAACW,OAAe,EAAEf,KAAa,EAAU;IACtE;IACA,IAAIe,OAAO,CAACJ,QAAQ,CAAC,IAAI,CAAC,EAAE;MACxB,OAAOI,OAAO,CAACF,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAGb,KAAK;IAC7C;IACA,OAAOe,OAAO;EAClB;AACJ","ignoreList":[]}
|
package/utils/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export * from "./isValidRegionName.js";
|
|
|
8
8
|
export * from "./isValidVariantName.js";
|
|
9
9
|
export * from "./measureDuration.js";
|
|
10
10
|
export * from "./requireConfig.js";
|
|
11
|
+
export * from "./toImportSpecifier.js";
|
|
11
12
|
export * from "./projectSdkContext.js";
|
|
12
13
|
export * from "./registerExtension.js";
|
package/utils/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./isValidRegionName.js";
|
|
|
8
8
|
export * from "./isValidVariantName.js";
|
|
9
9
|
export * from "./measureDuration.js";
|
|
10
10
|
export * from "./requireConfig.js";
|
|
11
|
+
export * from "./toImportSpecifier.js";
|
|
11
12
|
export * from "./projectSdkContext.js";
|
|
12
13
|
export * from "./registerExtension.js";
|
|
13
14
|
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./constants.js\";\nexport * from \"./createPathResolver.js\";\nexport * from \"./getRandomColorForString.js\";\nexport * from \"./getStackName.js\";\nexport * from \"./getTemplatesFolderPath.js\";\nexport * from \"./ExtensionSrcResolver.js\";\nexport * from \"./isValidRegionName.js\";\nexport * from \"./isValidVariantName.js\";\nexport * from \"./measureDuration.js\";\nexport * from \"./requireConfig.js\";\nexport * from \"./projectSdkContext.js\";\nexport * from \"./registerExtension.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./constants.js\";\nexport * from \"./createPathResolver.js\";\nexport * from \"./getRandomColorForString.js\";\nexport * from \"./getStackName.js\";\nexport * from \"./getTemplatesFolderPath.js\";\nexport * from \"./ExtensionSrcResolver.js\";\nexport * from \"./isValidRegionName.js\";\nexport * from \"./isValidVariantName.js\";\nexport * from \"./measureDuration.js\";\nexport * from \"./requireConfig.js\";\nexport * from \"./toImportSpecifier.js\";\nexport * from \"./projectSdkContext.js\";\nexport * from \"./registerExtension.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/utils/requireConfig.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { toImportSpecifier } from "./toImportSpecifier.js";
|
|
1
2
|
export const requireConfig = async input => {
|
|
2
|
-
return await import(input).then(m => m.default ?? m);
|
|
3
|
+
return await import(toImportSpecifier(input)).then(m => m.default ?? m);
|
|
3
4
|
};
|
|
4
5
|
export const requireConfigWithExecute = async (configPath, params) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const module = await import(toImportSpecifier(configPath));
|
|
7
|
+
|
|
8
|
+
// TODO: https://github.com/orgs/webiny/projects/32/views/2?pane=issue&itemId=125453089
|
|
9
|
+
const config = module.default.default ?? module.default ?? module;
|
|
10
|
+
if (typeof config === "function") {
|
|
11
|
+
return config(params);
|
|
8
12
|
}
|
|
9
|
-
return
|
|
13
|
+
return config;
|
|
10
14
|
};
|
|
11
15
|
|
|
12
16
|
//# sourceMappingURL=requireConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["requireConfig","input","then","m","default","requireConfigWithExecute","configPath","params","
|
|
1
|
+
{"version":3,"names":["toImportSpecifier","requireConfig","input","then","m","default","requireConfigWithExecute","configPath","params","module","config"],"sources":["requireConfig.ts"],"sourcesContent":["import { toImportSpecifier } from \"./toImportSpecifier.js\";\n\nexport interface IRequireConfigOptions {\n env: string;\n variant: string | undefined;\n region: string | undefined;\n debug?: boolean;\n cwd: string;\n}\n\nexport interface IRequireConfigResult {\n commands: {\n build: (options: IRequireConfigOptions) => Promise<void>;\n\n // TODO: revisit context.\n watch: (options: IRequireConfigOptions, context: any) => Promise<void>;\n };\n}\n\nexport interface IRequireConfigParams {\n [key: string]: Record<string, any>;\n}\n\nexport const requireConfig = async <T extends IRequireConfigResult = IRequireConfigResult>(\n input: string\n): Promise<T> => {\n return await import(toImportSpecifier(input)).then(m => m.default ?? m);\n};\n\nexport const requireConfigWithExecute = async <\n T extends IRequireConfigResult = IRequireConfigResult\n>(\n configPath: string,\n params: IRequireConfigParams\n): Promise<T> => {\n const module = await import(toImportSpecifier(configPath));\n\n // TODO: https://github.com/orgs/webiny/projects/32/views/2?pane=issue&itemId=125453089\n const config = module.default.default ?? module.default ?? module;\n\n if (typeof config === \"function\") {\n return config(params);\n }\n\n return config;\n};\n"],"mappings":"AAAA,SAASA,iBAAiB;AAuB1B,OAAO,MAAMC,aAAa,GAAG,MACzBC,KAAa,IACA;EACb,OAAO,MAAM,MAAM,CAACF,iBAAiB,CAACE,KAAK,CAAC,CAAC,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,IAAID,CAAC,CAAC;AAC3E,CAAC;AAED,OAAO,MAAME,wBAAwB,GAAG,MAAAA,CAGpCC,UAAkB,EAClBC,MAA4B,KACf;EACb,MAAMC,MAAM,GAAG,MAAM,MAAM,CAACT,iBAAiB,CAACO,UAAU,CAAC,CAAC;;EAE1D;EACA,MAAMG,MAAM,GAAGD,MAAM,CAACJ,OAAO,CAACA,OAAO,IAAII,MAAM,CAACJ,OAAO,IAAII,MAAM;EAEjE,IAAI,OAAOC,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM,CAACF,MAAM,CAAC;EACzB;EAEA,OAAOE,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a file path to a valid ESM import specifier.
|
|
6
|
+
* On Windows, absolute paths (e.g. "C:/...") must be file:// URLs for the ESM loader.
|
|
7
|
+
*/
|
|
8
|
+
export const toImportSpecifier = inputPath => {
|
|
9
|
+
return path.isAbsolute(inputPath) ? pathToFileURL(inputPath).href : inputPath;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=toImportSpecifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["path","pathToFileURL","toImportSpecifier","inputPath","isAbsolute","href"],"sources":["toImportSpecifier.ts"],"sourcesContent":["import path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Converts a file path to a valid ESM import specifier.\n * On Windows, absolute paths (e.g. \"C:/...\") must be file:// URLs for the ESM loader.\n */\nexport const toImportSpecifier = (inputPath: string): string => {\n return path.isAbsolute(inputPath) ? pathToFileURL(inputPath).href : inputPath;\n};\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,aAAa,QAAQ,UAAU;;AAExC;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAIC,SAAiB,IAAa;EAC5D,OAAOH,IAAI,CAACI,UAAU,CAACD,SAAS,CAAC,GAAGF,aAAa,CAACE,SAAS,CAAC,CAACE,IAAI,GAAGF,SAAS;AACjF,CAAC","ignoreList":[]}
|
package/exports/infra/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { LoggerService as Logger } from "../../abstractions/services/LoggerService.js";
|
|
2
|
-
export { UiService as Ui } from "../../abstractions/services/UiService.js";
|
|
3
|
-
export { AfterBuild as AfterBuildHook } from "../../abstractions/features/hooks/AfterBuild.js";
|
|
4
|
-
export { BeforeBuild as BeforeBuildHook } from "../../abstractions/features/hooks/BeforeBuild.js";
|
|
5
|
-
export { AfterDeploy as AfterDeployHook } from "../../abstractions/features/hooks/AfterDeploy.js";
|
|
6
|
-
export { BeforeDeploy as BeforeDeployHook } from "../../abstractions/features/hooks/BeforeDeploy.js";
|
|
7
|
-
export { BeforeWatch as BeforeWatchHook } from "../../abstractions/features/hooks/BeforeWatch.js";
|
|
8
|
-
export { EnvVar } from "../../extensions/EnvVar.js";
|
package/exports/infra/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { LoggerService as Logger } from "../../abstractions/services/LoggerService.js";
|
|
2
|
-
export { UiService as Ui } from "../../abstractions/services/UiService.js";
|
|
3
|
-
export { AfterBuild as AfterBuildHook } from "../../abstractions/features/hooks/AfterBuild.js";
|
|
4
|
-
export { BeforeBuild as BeforeBuildHook } from "../../abstractions/features/hooks/BeforeBuild.js";
|
|
5
|
-
export { AfterDeploy as AfterDeployHook } from "../../abstractions/features/hooks/AfterDeploy.js";
|
|
6
|
-
export { BeforeDeploy as BeforeDeployHook } from "../../abstractions/features/hooks/BeforeDeploy.js";
|
|
7
|
-
export { BeforeWatch as BeforeWatchHook } from "../../abstractions/features/hooks/BeforeWatch.js";
|
|
8
|
-
export { EnvVar } from "../../extensions/EnvVar.js";
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface IRequireConfigOptions {
|
|
2
|
-
env: string;
|
|
3
|
-
variant: string | undefined;
|
|
4
|
-
region: string | undefined;
|
|
5
|
-
debug?: boolean;
|
|
6
|
-
cwd: string;
|
|
7
|
-
}
|
|
8
|
-
export interface IRequireConfigResult {
|
|
9
|
-
commands: {
|
|
10
|
-
build: (options: IRequireConfigOptions) => Promise<void>;
|
|
11
|
-
watch: (options: IRequireConfigOptions, context: any) => Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface IRequireConfigParams {
|
|
15
|
-
[key: string]: Record<string, any>;
|
|
16
|
-
}
|
|
17
|
-
export declare const requireConfig: <T extends IRequireConfigResult = IRequireConfigResult>(input: string) => Promise<T>;
|
|
18
|
-
export declare const requireConfigWithExecute: <T extends IRequireConfigResult = IRequireConfigResult>(configPath: string, params: IRequireConfigParams) => Promise<T>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const requireConfig = async input => {
|
|
2
|
-
return await import(input).then(m => m.default ?? m);
|
|
3
|
-
};
|
|
4
|
-
export const requireConfigWithExecute = async (configPath, params) => {
|
|
5
|
-
const module = await import(configPath);
|
|
6
|
-
|
|
7
|
-
// TODO: https://github.com/orgs/webiny/projects/32/views/2?pane=issue&itemId=125453089
|
|
8
|
-
const config = module.default.default ?? module.default ?? module;
|
|
9
|
-
if (typeof config === "function") {
|
|
10
|
-
return config(params);
|
|
11
|
-
}
|
|
12
|
-
return config;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=requireConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["requireConfig","input","then","m","default","requireConfigWithExecute","configPath","params","module","config"],"sources":["requireConfig.ts"],"sourcesContent":["export interface IRequireConfigOptions {\n env: string;\n variant: string | undefined;\n region: string | undefined;\n debug?: boolean;\n cwd: string;\n}\n\nexport interface IRequireConfigResult {\n commands: {\n build: (options: IRequireConfigOptions) => Promise<void>;\n\n // TODO: revisit context.\n watch: (options: IRequireConfigOptions, context: any) => Promise<void>;\n };\n}\n\nexport interface IRequireConfigParams {\n [key: string]: Record<string, any>;\n}\n\nexport const requireConfig = async <T extends IRequireConfigResult = IRequireConfigResult>(\n input: string\n): Promise<T> => {\n return await import(input).then(m => m.default ?? m);\n};\n\nexport const requireConfigWithExecute = async <\n T extends IRequireConfigResult = IRequireConfigResult\n>(\n configPath: string,\n params: IRequireConfigParams\n): Promise<T> => {\n const module = await import(configPath);\n\n // TODO: https://github.com/orgs/webiny/projects/32/views/2?pane=issue&itemId=125453089\n const config = module.default.default ?? module.default ?? module;\n\n if (typeof config === \"function\") {\n return config(params);\n }\n\n return config;\n};\n"],"mappings":"AAqBA,OAAO,MAAMA,aAAa,GAAG,MACzBC,KAAa,IACA;EACb,OAAO,MAAM,MAAM,CAACA,KAAK,CAAC,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,IAAID,CAAC,CAAC;AACxD,CAAC;AAED,OAAO,MAAME,wBAAwB,GAAG,MAAAA,CAGpCC,UAAkB,EAClBC,MAA4B,KACf;EACb,MAAMC,MAAM,GAAG,MAAM,MAAM,CAACF,UAAU,CAAC;;EAEvC;EACA,MAAMG,MAAM,GAAGD,MAAM,CAACJ,OAAO,CAACA,OAAO,IAAII,MAAM,CAACJ,OAAO,IAAII,MAAM;EAEjE,IAAI,OAAOC,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM,CAACF,MAAM,CAAC;EACzB;EAEA,OAAOE,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface IRequireConfigOptions {
|
|
2
|
-
env: string;
|
|
3
|
-
variant: string | undefined;
|
|
4
|
-
region: string | undefined;
|
|
5
|
-
debug?: boolean;
|
|
6
|
-
cwd: string;
|
|
7
|
-
}
|
|
8
|
-
export interface IRequireConfigResult {
|
|
9
|
-
commands: {
|
|
10
|
-
build: (options: IRequireConfigOptions) => Promise<void>;
|
|
11
|
-
watch: (options: IRequireConfigOptions, context: any) => Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface IRequireConfigParams {
|
|
15
|
-
[key: string]: Record<string, any>;
|
|
16
|
-
}
|
|
17
|
-
export declare const requireConfig: <T extends IRequireConfigResult = IRequireConfigResult>(input: string) => Promise<T>;
|
|
18
|
-
export declare const requireConfigWithExecute: <T extends IRequireConfigResult = IRequireConfigResult>(configPath: string, params: IRequireConfigParams) => Promise<T>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const requireConfig = async input => {
|
|
2
|
-
return await import(input).then(m => m.default ?? m);
|
|
3
|
-
};
|
|
4
|
-
export const requireConfigWithExecute = async (configPath, params) => {
|
|
5
|
-
const module = await import(configPath);
|
|
6
|
-
|
|
7
|
-
// TODO: https://github.com/orgs/webiny/projects/32/views/2?pane=issue&itemId=125453089
|
|
8
|
-
const config = module.default.default ?? module.default ?? module;
|
|
9
|
-
if (typeof config === "function") {
|
|
10
|
-
return config(params);
|
|
11
|
-
}
|
|
12
|
-
return config;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=requireConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["requireConfig","input","then","m","default","requireConfigWithExecute","configPath","params","module","config"],"sources":["requireConfig.ts"],"sourcesContent":["export interface IRequireConfigOptions {\n env: string;\n variant: string | undefined;\n region: string | undefined;\n debug?: boolean;\n cwd: string;\n}\n\nexport interface IRequireConfigResult {\n commands: {\n build: (options: IRequireConfigOptions) => Promise<void>;\n\n // TODO: revisit context.\n watch: (options: IRequireConfigOptions, context: any) => Promise<void>;\n };\n}\n\nexport interface IRequireConfigParams {\n [key: string]: Record<string, any>;\n}\n\nexport const requireConfig = async <T extends IRequireConfigResult = IRequireConfigResult>(\n input: string\n): Promise<T> => {\n return await import(input).then(m => m.default ?? m);\n};\n\nexport const requireConfigWithExecute = async <\n T extends IRequireConfigResult = IRequireConfigResult\n>(\n configPath: string,\n params: IRequireConfigParams\n): Promise<T> => {\n const module = await import(configPath);\n\n // TODO: https://github.com/orgs/webiny/projects/32/views/2?pane=issue&itemId=125453089\n const config = module.default.default ?? module.default ?? module;\n\n if (typeof config === \"function\") {\n return config(params);\n }\n\n return config;\n};\n"],"mappings":"AAqBA,OAAO,MAAMA,aAAa,GAAG,MACzBC,KAAa,IACA;EACb,OAAO,MAAM,MAAM,CAACA,KAAK,CAAC,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,IAAID,CAAC,CAAC;AACxD,CAAC;AAED,OAAO,MAAME,wBAAwB,GAAG,MAAAA,CAGpCC,UAAkB,EAClBC,MAA4B,KACf;EACb,MAAMC,MAAM,GAAG,MAAM,MAAM,CAACF,UAAU,CAAC;;EAEvC;EACA,MAAMG,MAAM,GAAGD,MAAM,CAACJ,OAAO,CAACA,OAAO,IAAII,MAAM,CAACJ,OAAO,IAAII,MAAM;EAEjE,IAAI,OAAOC,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM,CAACF,MAAM,CAAC;EACzB;EAEA,OAAOE,MAAM;AACjB,CAAC","ignoreList":[]}
|