crownpeak-dxm-vuejs-sdk
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -56,2 +56,14 @@ const dotenv = require("dotenv"); | ||
} | ||
if (options.only && options.only.length) { | ||
components = components.filter(c => options.only.indexOf(c.name) >= 0); | ||
pages = pages.filter(p => options.only.indexOf(p.name) >= 0); | ||
wrappers = wrappers.filter(w => options.only.indexOf(w.name) >= 0); | ||
uploads = uploads.filter(u => options.only.indexOf(u.name) >= 0); | ||
// Set the --ignore-circular-dependencies to get around potential missing dependencies issues here | ||
if (options["ignore-circular-dependencies"] !== true && options.ignorecirculardependencies !== true) { | ||
options["ignore-circular-dependencies"] = | ||
options.ignorecirculardependencies = | ||
options["do-not-warn-about-circular-dependencies"] = true; | ||
} | ||
} | ||
@@ -58,0 +70,0 @@ scaffoldCore.process(cms, options, components, pages, wrappers, uploads); |
const babelParser = require("@babel/parser"); | ||
const cssParser = require("./css"); | ||
const utils = require("crownpeak-dxm-sdk-core/lib/crownpeak/utils"); | ||
@@ -11,3 +13,3 @@ let _componentName = ""; | ||
const parse = (content) => { | ||
const parse = (content, file) => { | ||
let match = reTemplate.exec(content); | ||
@@ -32,2 +34,3 @@ if (!match) return; | ||
let results = []; | ||
let uploads = []; | ||
let imports = []; | ||
@@ -59,2 +62,3 @@ let dependencies = []; | ||
if (extnds && extnds.value.name === "CmsComponent" && name) { | ||
const cmsProps = processCmsProperties(content, name, part.declaration, imports); | ||
name = name.value.value; | ||
@@ -66,3 +70,5 @@ //console.log(`Found component ${name} extending CmsComponent`); | ||
if (result) { | ||
results.push({name: name, content: finalProcessMarkup(result), dependencies: dependencies}); | ||
const processedResult = utils.replaceAssets(file, finalProcessMarkup(result), cssParser, true); | ||
uploads = uploads.concat(processedResult.uploads); | ||
results.push({name: name, content: processedResult.content, folder: cmsProps.folder, dependencies: dependencies}); | ||
} | ||
@@ -73,3 +79,3 @@ } | ||
} | ||
return results; | ||
return { components: results, uploads: uploads }; | ||
}; | ||
@@ -276,2 +282,21 @@ | ||
const processCmsProperties = (content, name, declaration, imports) => { | ||
return { | ||
folder: getCmsProperty(declaration, "cmsFolder", "") | ||
}; | ||
}; | ||
const getCmsProperty = (declaration, name, defaultValue) => { | ||
const properties = declaration.properties; | ||
for (let i = 0, len = properties.length; i < len; i++) { | ||
const prop = properties[i]; | ||
if (prop.type === "ObjectProperty" | ||
&& prop.key && prop.key.name === name | ||
&& prop.value) { | ||
return prop.value.value; | ||
} | ||
} | ||
return defaultValue; | ||
}; | ||
const cmsFieldTypeToString = (cmsFieldType) => { | ||
@@ -278,0 +303,0 @@ if (cmsFieldType === "IMAGE") return "Src"; |
@@ -54,11 +54,12 @@ const babelParser = require("@babel/parser"); | ||
if (extnds && name && (extnds.value.name === "CmsDynamicPage" || extnds.value.name === "CmsStaticPage")) { | ||
const cmsProps = processCmsProperties(content, name, part.declaration, imports); | ||
name = name.value.value; | ||
//console.log(`Found page ${name} extending ${extnds.value.name}`); | ||
const data = processCmsPage(content, ast, name, part.declaration, imports); | ||
if (data && data.components) { | ||
const result = processCmsPageTemplate(content, name, template, data.components, imports); | ||
const components = processCmsPage(content, ast, name, part.declaration, imports); | ||
if (components) { | ||
const result = processCmsPageTemplate(content, name, template, components, imports); | ||
if (result) { | ||
const processedResult = utils.replaceAssets(file, finalProcessMarkup(result), cssParser); | ||
uploads = uploads.concat(processedResult.uploads); | ||
results.push({name: name, content: processedResult.content, wrapper: data.wrapper}); | ||
results.push({name: name, content: processedResult.content, wrapper: cmsProps.wrapper, useTmf: cmsProps.useTmf === true, suppressFolder: cmsProps.suppressFolder === true, suppressModel: cmsProps.suppressModel === true}); | ||
} | ||
@@ -72,2 +73,24 @@ } | ||
const processCmsProperties = (content, name, declaration, imports) => { | ||
return { | ||
suppressFolder: getCmsProperty(declaration, "cmsSuppressFolder", false), | ||
suppressModel: getCmsProperty(declaration, "cmsSuppressModel", false), | ||
useTmf: getCmsProperty(declaration, "cmsUseTmf", false), | ||
wrapper: getCmsProperty(declaration, "cmsWrapper", undefined) | ||
}; | ||
}; | ||
const getCmsProperty = (declaration, name, defaultValue) => { | ||
const properties = declaration.properties; | ||
for (let i = 0, len = properties.length; i < len; i++) { | ||
const prop = properties[i]; | ||
if (prop.type === "ObjectProperty" | ||
&& prop.key && prop.key.name === name | ||
&& prop.value) { | ||
return prop.value.value; | ||
} | ||
} | ||
return defaultValue; | ||
}; | ||
const initialProcessMarkup = (content) => { | ||
@@ -152,8 +175,3 @@ // TODO: find a way to run this without breaking the ability to make replacements | ||
} | ||
let wrapper = declaration.properties.find(p => p.type === "ObjectProperty" && p.key.name === "cmsWrapper"); | ||
if (wrapper) { | ||
//console.log(`Found reference to wrapper [${wrapper}]`); | ||
wrapper = wrapper.value.value; | ||
} | ||
return {components: results, wrapper: wrapper}; | ||
return results; | ||
}; | ||
@@ -160,0 +178,0 @@ |
@@ -21,3 +21,5 @@ const fs = require("fs"); | ||
//console.log(`Found component in ${file}`); | ||
components = componentParser.parse(content); | ||
const temp = componentParser.parse(content, file); | ||
components = temp.components; | ||
uploads = temp.uploads; | ||
} | ||
@@ -24,0 +26,0 @@ if (rePage.test(content)) { |
import Vue from 'vue'; | ||
export default class CmsComponent extends Vue { | ||
cmsFolder?: string; | ||
created(): void; | ||
} |
@@ -28,3 +28,5 @@ "use strict"; | ||
function CmsComponent() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.cmsFolder = ""; | ||
return _this; | ||
} | ||
@@ -31,0 +33,0 @@ CmsComponent.prototype.created = function () { |
@@ -7,3 +7,6 @@ import Vue from 'vue'; | ||
cmsWrapper?: string; | ||
cmsUseTmf: boolean; | ||
cmsSuppressModel: boolean; | ||
cmsSuppressFolder: boolean; | ||
created(): void; | ||
} |
@@ -28,3 +28,7 @@ "use strict"; | ||
function CmsPage() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.cmsUseTmf = false; | ||
_this.cmsSuppressModel = false; | ||
_this.cmsSuppressFolder = false; | ||
return _this; | ||
} | ||
@@ -31,0 +35,0 @@ CmsPage.prototype.created = function () { |
{ | ||
"name": "crownpeak-dxm-vuejs-sdk", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Crownpeak Digital Experience Management (DXM) Software Development Kit (SDK) for Vue.js has been constructed to assist the Single Page App developer in developing client-side applications that leverage DXM for content management purposes.", | ||
@@ -10,3 +10,3 @@ "repository": "https://github.com/Crownpeak/DXM-VueJS-SDK", | ||
"@babel/parser": "^7.9.6", | ||
"crownpeak-dxm-sdk-core": "^2.3.0", | ||
"crownpeak-dxm-sdk-core": "^2.4.0", | ||
"dotenv": "^8.2.0", | ||
@@ -13,0 +13,0 @@ "vue": "^2.6.11", |
@@ -53,2 +53,3 @@ <a href="https://www.crownpeak.com" target="_blank">![Crownpeak Logo](https://github.com/Crownpeak/DXM-VueJS-SDK/raw/master/images/crownpeak-logo.png?raw=true "Crownpeak Logo")</a> | ||
| 2.2.0 | 2020SEP03 | Add support for indexed fields and cp-scaffold. Bug fixes. | | ||
| 2.3.0 | 2020OCT01 | Preserve paths for uploads, support uploads from pages and wrappers. Bug fixes. | | ||
| 2.3.0 | 2020OCT01 | Preserve paths for uploads, support uploads from pages and wrappers. Bug fixes. | | ||
| 2.4.0 | 2020OCT09 | Improved uploading and relinking, new page and component creation settings, new --only option. Bug fixes. | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58291
963
54