dynamo-bao 0.2.3 → 0.2.4
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/bin/generators/model.js +19 -15
- package/package.json +1 -1
package/bin/generators/model.js
CHANGED
|
@@ -135,21 +135,25 @@ function generateModelClass(
|
|
|
135
135
|
|
|
136
136
|
logger.debug("fieldResolver customFields", fieldResolver.customFieldsPath);
|
|
137
137
|
|
|
138
|
-
//
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
138
|
+
// Generate custom field imports only if we have custom fields and a path
|
|
139
|
+
const customFieldImports =
|
|
140
|
+
customFields.size > 0 && fieldResolver.customFieldsPath
|
|
141
|
+
? Array.from(customFields)
|
|
142
|
+
.map((fieldType) => {
|
|
143
|
+
// Remove 'Field' suffix before converting to kebab case
|
|
144
|
+
const baseName = fieldType.replace(/Field$/, "");
|
|
145
|
+
const kebabName = baseName
|
|
146
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
147
|
+
.toLowerCase();
|
|
148
|
+
// get relative path for fieldResolver.customFieldsPath from projectPath
|
|
149
|
+
const relativePath = path.relative(
|
|
150
|
+
outputDir,
|
|
151
|
+
fieldResolver.customFieldsPath,
|
|
152
|
+
);
|
|
153
|
+
return `const { ${fieldType} } = require('${relativePath}/${kebabName}-field');`;
|
|
154
|
+
})
|
|
155
|
+
.join("\n")
|
|
156
|
+
: "";
|
|
153
157
|
|
|
154
158
|
// Generate the final code with separated imports
|
|
155
159
|
return `// 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨 🧨
|