strapi/tests/e2e/utils/dts-export.ts

98 lines
2.5 KiB
TypeScript
Raw Normal View History

feat: move rw to plugin (#19937) * chore: initiate moving CM to own package * chore: refactor to handle routes * chore: init review-workflows-package * chore: fix build * chore: refactor review-workflows fe * chore: fix unit suite * feat: move rw to plugin * fix: build * fix: start up * chore: clean things up * fix: peer dependencies * chore(wip): refactor rw fe * chore: re-add admin ui * chore: fix tests & linter * chore: re-implement drag layer * fix: type * feat: review-workflow middlewares * chore: send params to CM endpoints * fix: use layout options as well, let that have the final say, just incase * feat: use doc id and locale for entity assignee and stage * fix: api tests * fix: cm updates when we update fields * chore: cleanup edit-view e2e tests * fix: build * fix: useDocumentLayout for RW options * test: fix fe tests * fix: ts * test(e2e): add review-workflow e2e tests * chore: fix bad import for cli tests * chore: delete old e2e data * chore: import EVERYTHING for DTS * chore: update dataset * fix: e2e script * fix: stage permissions * chore: remove duplicate settings menu link * fix: workflow middleware * chore: change permission * test(e2e): fix RW tests * chore: ignore dynamic attributes in DTS Co-Authored-By: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com> * chore: make settings rw e2e run on EE only * test(e2e): fix them all pls * fix: admin stage transition uid name * chore: fix firefox e2e ce tests --------- Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com>
2024-04-12 10:58:38 +02:00
'use strict';
const {
file: {
providers: { createLocalFileDestinationProvider },
},
strapi: {
providers: { createLocalStrapiSourceProvider },
},
engine: { createTransferEngine },
} = require('@strapi/data-transfer');
feat: move rw to plugin (#19937) * chore: initiate moving CM to own package * chore: refactor to handle routes * chore: init review-workflows-package * chore: fix build * chore: refactor review-workflows fe * chore: fix unit suite * feat: move rw to plugin * fix: build * fix: start up * chore: clean things up * fix: peer dependencies * chore(wip): refactor rw fe * chore: re-add admin ui * chore: fix tests & linter * chore: re-implement drag layer * fix: type * feat: review-workflow middlewares * chore: send params to CM endpoints * fix: use layout options as well, let that have the final say, just incase * feat: use doc id and locale for entity assignee and stage * fix: api tests * fix: cm updates when we update fields * chore: cleanup edit-view e2e tests * fix: build * fix: useDocumentLayout for RW options * test: fix fe tests * fix: ts * test(e2e): add review-workflow e2e tests * chore: fix bad import for cli tests * chore: delete old e2e data * chore: import EVERYTHING for DTS * chore: update dataset * fix: e2e script * fix: stage permissions * chore: remove duplicate settings menu link * fix: workflow middleware * chore: change permission * test(e2e): fix RW tests * chore: ignore dynamic attributes in DTS Co-Authored-By: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com> * chore: make settings rw e2e run on EE only * test(e2e): fix them all pls * fix: admin stage transition uid name * chore: fix firefox e2e ce tests --------- Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com>
2024-04-12 10:58:38 +02:00
const { createStrapi } = require('@strapi/strapi');
const { ALLOWED_CONTENT_TYPES } = require('../constants');
/**
* Export the data from a strapi project.
* This script should be run as `node <path-to>/dts-export.js [exportFilePath]` from the
* root directory of a strapi project e.g. `/examples/kitchensink`. Remember to import
* the `with-admin` tar file into the project first because the tests rely on the data.
*/
feat: move rw to plugin (#19937) * chore: initiate moving CM to own package * chore: refactor to handle routes * chore: init review-workflows-package * chore: fix build * chore: refactor review-workflows fe * chore: fix unit suite * feat: move rw to plugin * fix: build * fix: start up * chore: clean things up * fix: peer dependencies * chore(wip): refactor rw fe * chore: re-add admin ui * chore: fix tests & linter * chore: re-implement drag layer * fix: type * feat: review-workflow middlewares * chore: send params to CM endpoints * fix: use layout options as well, let that have the final say, just incase * feat: use doc id and locale for entity assignee and stage * fix: api tests * fix: cm updates when we update fields * chore: cleanup edit-view e2e tests * fix: build * fix: useDocumentLayout for RW options * test: fix fe tests * fix: ts * test(e2e): add review-workflow e2e tests * chore: fix bad import for cli tests * chore: delete old e2e data * chore: import EVERYTHING for DTS * chore: update dataset * fix: e2e script * fix: stage permissions * chore: remove duplicate settings menu link * fix: workflow middleware * chore: change permission * test(e2e): fix RW tests * chore: ignore dynamic attributes in DTS Co-Authored-By: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com> * chore: make settings rw e2e run on EE only * test(e2e): fix them all pls * fix: admin stage transition uid name * chore: fix firefox e2e ce tests --------- Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com>
2024-04-12 10:58:38 +02:00
const exportData = async () => {
let args = process.argv.slice(2);
if (args.length !== 1) {
console.error('Please provide the export file name as a parameter.');
process.exit(1);
}
const strapi = await createStrapiInstance();
const source = createSourceProvider(strapi);
const destination = createDestinationProvider(args[0]);
const engine = createTransferEngine(source, destination, {
versionStrategy: 'ignore', // for an export to file, versionStrategy will always be skipped
schemaStrategy: 'ignore', // for an export to file, schemaStrategy will always be skipped
transforms: {
links: [
{
filter(link) {
return (
ALLOWED_CONTENT_TYPES.includes(link.left.type) &&
ALLOWED_CONTENT_TYPES.includes(link.right.type)
);
},
},
],
entities: [
{
filter(entity) {
return ALLOWED_CONTENT_TYPES.includes(entity.type);
},
},
],
},
});
engine.diagnostics.onDiagnostic(console.log);
try {
const results = await engine.transfer();
console.log(JSON.stringify(results.engine, null, 2));
} catch {
console.error('Export process failed.');
process.exit(1);
}
process.exit(0);
};
const createSourceProvider = (strapi) =>
createLocalStrapiSourceProvider({
async getStrapi() {
return strapi;
},
});
const createDestinationProvider = (filePath) =>
createLocalFileDestinationProvider({
file: { path: filePath },
encryption: { enabled: false },
compression: { enabled: false },
});
const createStrapiInstance = async (logLevel = 'error') => {
feat: move rw to plugin (#19937) * chore: initiate moving CM to own package * chore: refactor to handle routes * chore: init review-workflows-package * chore: fix build * chore: refactor review-workflows fe * chore: fix unit suite * feat: move rw to plugin * fix: build * fix: start up * chore: clean things up * fix: peer dependencies * chore(wip): refactor rw fe * chore: re-add admin ui * chore: fix tests & linter * chore: re-implement drag layer * fix: type * feat: review-workflow middlewares * chore: send params to CM endpoints * fix: use layout options as well, let that have the final say, just incase * feat: use doc id and locale for entity assignee and stage * fix: api tests * fix: cm updates when we update fields * chore: cleanup edit-view e2e tests * fix: build * fix: useDocumentLayout for RW options * test: fix fe tests * fix: ts * test(e2e): add review-workflow e2e tests * chore: fix bad import for cli tests * chore: delete old e2e data * chore: import EVERYTHING for DTS * chore: update dataset * fix: e2e script * fix: stage permissions * chore: remove duplicate settings menu link * fix: workflow middleware * chore: change permission * test(e2e): fix RW tests * chore: ignore dynamic attributes in DTS Co-Authored-By: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com> * chore: make settings rw e2e run on EE only * test(e2e): fix them all pls * fix: admin stage transition uid name * chore: fix firefox e2e ce tests --------- Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com>
2024-04-12 10:58:38 +02:00
const app = createStrapi();
app.log.level = logLevel;
const loadedApp = await app.load();
return loadedApp;
};
feat: move rw to plugin (#19937) * chore: initiate moving CM to own package * chore: refactor to handle routes * chore: init review-workflows-package * chore: fix build * chore: refactor review-workflows fe * chore: fix unit suite * feat: move rw to plugin * fix: build * fix: start up * chore: clean things up * fix: peer dependencies * chore(wip): refactor rw fe * chore: re-add admin ui * chore: fix tests & linter * chore: re-implement drag layer * fix: type * feat: review-workflow middlewares * chore: send params to CM endpoints * fix: use layout options as well, let that have the final say, just incase * feat: use doc id and locale for entity assignee and stage * fix: api tests * fix: cm updates when we update fields * chore: cleanup edit-view e2e tests * fix: build * fix: useDocumentLayout for RW options * test: fix fe tests * fix: ts * test(e2e): add review-workflow e2e tests * chore: fix bad import for cli tests * chore: delete old e2e data * chore: import EVERYTHING for DTS * chore: update dataset * fix: e2e script * fix: stage permissions * chore: remove duplicate settings menu link * fix: workflow middleware * chore: change permission * test(e2e): fix RW tests * chore: ignore dynamic attributes in DTS Co-Authored-By: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com> * chore: make settings rw e2e run on EE only * test(e2e): fix them all pls * fix: admin stage transition uid name * chore: fix firefox e2e ce tests --------- Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> Co-authored-by: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com>
2024-04-12 10:58:38 +02:00
module.exports = {
exportData,
};