UNPKG

@wep2/cli

Version:

Command line for Wepublish Editor 2

52 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.migrateSchema = exports.unzipWep2 = exports.update = void 0; const childProcess = require('child_process'); function update() { unzipWep2(); migrateSchema(); } exports.update = update; /** * Create necessary directories and copying files from the WePublish Editor 2 npm package */ async function unzipWep2(projectName = null) { console.log('Unzipping WePublish Editor 2 files...'); const options = { stdio: [0, 1, 2] }; if (projectName) { options['cwd'] = `./${projectName}`; } try { await childProcess .execSync(`mkdir -p schema && cp -R ./node_modules/@wep2/editor/schema/* ./schema/`, options); } catch (e) { console.log(e); } // TODO: unzip all extensions console.log('Todo: Unzip Directus extensions.'); } exports.unzipWep2 = unzipWep2; /** * Migrate the Directus database with the schema of the WePublish Editor 2 */ async function migrateSchema(projectName = null) { console.log('Implement WePublish Editor 2 schema to Directus...'); const options = { stdio: [0, 1, 2] }; if (projectName) { options['cwd'] = `./${projectName}`; } try { await childProcess .execSync('npx directus schema apply ./schema/schema.yaml', options); } catch (error) { console.log(error); } } exports.migrateSchema = migrateSchema; //# sourceMappingURL=update.js.map