Skip to content

QABACKLOG-1651 : add export site helper #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,17 @@ module.exports = (on, config) => {
```
## Open-Source

This is an Open-Source codebase, you can find more details about Open-Source @ Jahia [in this repository](https://github.com/Jahia/open-source)
This is an Open-Source codebase, you can find more details about Open-Source @ Jahia [in this repository](https://github.com/Jahia/open-source)

## Use jahia-cypress with local changes

During development time we often need to add or edit a method in jahia-cypress to use it somewhere else.
Here is the procedure test locally :
- do your changes in jahia-cypress
- execute command line > yarn build
- access the project where you want to call method from jahia-cypress (either jahia-ee, jexperience, ...)
- edit tests/package.json file
- find line "@jahia/cypress"
- set "@jahia/cypress": "path/to/your/local/jahia-cypress",
- execute command line > yarn install
- you can now use the new method from jahia-cypress
39 changes: 39 additions & 0 deletions src/utils/SiteHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,42 @@
SERVERNAME: config.serverName
});
};


// Exports a site from the server.
// - `serverUrl` (string): The URL of the server.
// - `siteToExport` (string): The key of the site to export.

Check failure on line 42 in src/utils/SiteHelper.ts

View workflow job for this annotation

GitHub Actions / Lint and build

More than 1 blank line not allowed
// - `exportFile` (string, optional): The name of the export file.
// - `exportPath` (string, optional): The path where the exported site will be saved.
// --In the case of a folder export The exported site will be stored in /var/jahia/exports/${exportPath} on your jahia server.
// --In the case of a export as zip file, the exported zip will be stored in ${exportPath}/${exportFile}
// - `isFolderExport` (boolean, optional): Indicates whether the export is a folder export to the server or a local export of the site as a zip file.

export const exportSite = (serverUrl: string, siteToExport : string, exportFile = 'export.zip', exportPath = '', isFolderExport = false): void => {
let exportUrl = `${serverUrl}/cms/export/default/${exportFile}?exportformat=site&live=true&sitebox=${siteToExport}`;
if (isFolderExport ) {
exportUrl = `${exportUrl}&exportPath=${exportPath}`;

Check warning on line 52 in src/utils/SiteHelper.ts

View workflow job for this annotation

GitHub Actions / Lint and build

Arrow function has too many parameters (5). Maximum allowed is 4
cy.request(exportUrl);
} else {

Check failure on line 54 in src/utils/SiteHelper.ts

View workflow job for this annotation

GitHub Actions / Lint and build

There should be no space before this paren
cy.request({method: 'GET', url: exportUrl, encoding: 'binary'})
.then(response => {
cy.writeFile(`${exportPath}/${exportFile}`, response.body, 'binary');
});
}
};

export const importSite = (serverUrl: string, pathToImportFolder : string, exportFile = 'export.zip', exportPath = ''): void => {
const importParameters = `importsInfos%5B%27roles.zip%27%5D.selected=true
&_importsInfos%5B%27roles.zip%27%5D.selected=&importsInfos%5B%27users.zip%27%5D.selected=true
&_importsInfos%5B%27users.zip%27%5D.selected=&importsInfos%5B%27

Check warning on line 65 in src/utils/SiteHelper.ts

View workflow job for this annotation

GitHub Actions / Lint and build

'exportFile' is assigned a value but never used

Check warning on line 65 in src/utils/SiteHelper.ts

View workflow job for this annotation

GitHub Actions / Lint and build

'exportPath' is assigned a value but never used
seoSiteToExporTest.zip%27%5D.selected=true&_importsInfos%5B%27seoSiteToExporTest.zip

Check warning on line 66 in src/utils/SiteHelper.ts

View workflow job for this annotation

GitHub Actions / Lint and build

'importParameters' is assigned a value but never used
%27%5D.selected=&importsInfos%5B%27seoSiteToExporTest.zip
%27%5D.siteTitle=seoSiteToExporTest&importsInfos%5B%27seoSiteToExporTest.zip%27%5D.siteKey=seoSiteToExporTest&importsInfos%5B%27seoSiteToExporTest.zip%27%5D.siteServername=localhost&importsInfos%5B%27seoSiteToExporTest.zip%27%5D.siteServernameAliases=&importsInfos%5B%27seoSiteToExporTest.zip%27%5D.templates=dx-base-demo-templates&_eventId_processImport=`;

// Let exportUrl = `${serverUrl}/cms/export/default/${exportFile}?exportformat=site&live=true&sitebox=${siteToExport}`;
// if (exportPath !== '') {
// exportUrl = `${exportUrl}&exportPath=${exportPath}`;
// }

// cy.request(exportUrl);
};
Loading