UNPKG

wp-setup

Version:

Easily create replicable local WordPress environments with Docker

55 lines 2.94 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { exists } from "../helpers/fs.js"; import { getProjectName } from '../helpers/cli.js'; import { renderAndSave } from '../services/template.js'; import AbstractCommand from './abstractCommand.js'; export default class MakerCommands extends AbstractCommand { constructor() { super(...arguments); this.init = (createTests) => __awaiter(this, void 0, void 0, function* () { const projectName = getProjectName(false); if (!createTests) { const setupFile = `${process.cwd()}/wp-setup.json`; if (exists(setupFile)) { this.error('wp-setup.json already exists.'); } yield renderAndSave('wp-setup.json', setupFile, { projectName }, true); this.log('Setup file created.'); this.log('Please edit wp-setup.json to configure the project.'); this.log('Run `wp-setup start` to start the project.'); this.success(); } const phpUnitFile = `${process.cwd()}/phpunit.xml`; if (exists(phpUnitFile)) { this.error('phpunit.xml already exists.'); } const testsDir = `${process.cwd()}/tests`; if (exists(testsDir)) { this.error('tests directory already exists.'); } const cwd = process.cwd(); const pluginName = cwd.split('/').pop(); const options = { projectName, pluginName }; const renderAndSaveTest = (template) => __awaiter(this, void 0, void 0, function* () { this.print(`Creating ${template} file...`); return renderAndSave(`test-suit/${template}`, `${cwd}/${template}`, options, true); }); yield renderAndSaveTest('phpunit.xml'); yield renderAndSaveTest('tests/bootstrap.php'); yield renderAndSaveTest('tests/Pest.php'); yield renderAndSaveTest('tests/TestCase.php'); yield renderAndSaveTest('tests/Feature/ExampleTest.php'); yield renderAndSaveTest('tests/Unit/ExampleTest.php'); this.success('Test files created.'); }); } } //# sourceMappingURL=makerCommands.js.map