2020-10-27 11:27:17 +01:00
|
|
|
'use strict';
|
|
|
|
|
2019-03-06 19:19:33 +01:00
|
|
|
const path = require('path');
|
|
|
|
const rimraf = require('rimraf');
|
2021-04-29 13:51:12 +02:00
|
|
|
const generateNew = require('../../packages/generators/app/lib/generate-new');
|
2019-03-06 19:19:33 +01:00
|
|
|
|
2021-06-23 20:18:13 +02:00
|
|
|
// FIXME
|
|
|
|
/* eslint-disable import/extensions */
|
|
|
|
|
2019-03-12 11:41:38 +01:00
|
|
|
/**
|
|
|
|
* Delete the testApp folder
|
|
|
|
* @param {string} appName - name of the app / folder where the app is located
|
|
|
|
*/
|
2019-03-06 19:19:33 +01:00
|
|
|
const cleanTestApp = appName => {
|
2019-03-12 11:41:38 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
rimraf(path.resolve(appName), err => {
|
|
|
|
if (err) reject(err);
|
2019-03-06 19:19:33 +01:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-03-12 11:41:38 +01:00
|
|
|
/**
|
|
|
|
* Runs strapi generate new
|
|
|
|
* @param {Object} options - Options
|
|
|
|
* @param {string} options.appName - Name of the app that will be created (also the name of the folder)
|
|
|
|
* @param {database} options.database - Arguments to create the testApp with the provided database params
|
|
|
|
*/
|
2019-03-25 16:37:46 +01:00
|
|
|
const generateTestApp = async ({ appName, database }) => {
|
2019-07-18 16:25:20 +02:00
|
|
|
const scope = {
|
2021-06-29 16:27:35 +02:00
|
|
|
database,
|
2019-07-18 16:25:20 +02:00
|
|
|
rootPath: path.resolve(appName),
|
2019-07-18 17:12:00 +02:00
|
|
|
name: appName,
|
2019-07-18 16:25:20 +02:00
|
|
|
// disable quickstart run app after creation
|
|
|
|
runQuickstartApp: false,
|
2020-10-09 18:43:15 +02:00
|
|
|
// use package version as strapiVersion (all packages have the same version);
|
2021-04-29 11:11:46 +02:00
|
|
|
strapiVersion: require('../../packages/core/strapi/package.json').version,
|
2019-07-18 16:25:20 +02:00
|
|
|
debug: false,
|
|
|
|
quick: false,
|
|
|
|
uuid: undefined,
|
|
|
|
deviceId: null,
|
|
|
|
// use yarn if available and --use-npm isn't true
|
|
|
|
useYarn: true,
|
|
|
|
installDependencies: false,
|
|
|
|
strapiDependencies: [
|
2021-04-29 13:51:12 +02:00
|
|
|
'@strapi/strapi',
|
|
|
|
'@strapi/admin',
|
|
|
|
'@strapi/utils',
|
|
|
|
'@strapi/plugin-content-type-builder',
|
|
|
|
'@strapi/plugin-content-manager',
|
|
|
|
'@strapi/plugin-users-permissions',
|
|
|
|
'@strapi/plugin-email',
|
|
|
|
'@strapi/plugin-upload',
|
|
|
|
'@strapi/plugin-graphql',
|
|
|
|
'@strapi/plugin-documentation',
|
|
|
|
'@strapi/plugin-i18n',
|
2019-07-18 16:25:20 +02:00
|
|
|
],
|
|
|
|
additionalsDependencies: {},
|
|
|
|
};
|
2019-04-16 18:05:12 +02:00
|
|
|
|
2019-07-18 16:25:20 +02:00
|
|
|
await generateNew(scope);
|
2019-03-06 19:19:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
cleanTestApp,
|
|
|
|
generateTestApp,
|
|
|
|
};
|