/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/create-block/lib/init-block.js
88 строк
2 KB
Marco Ciampini
ESLint: Remove legacy import suppressions (#81338)
07 авг 2026, 15:52
Не верифицирован
07 авг 2026, 15:52
8181ec4
Код
Авторство
О чём код?
const { join } = require( 'path' ); const { writeFile } = require( 'fs' ).promises; const makeDir = require( 'make-dir' ); const { info } = require( './log' ); const { writeOutputTemplate } = require( './output' ); async function initBlockJSON( { $schema, apiVersion, plugin, slug, namespace, title, version, description, category, attributes, supports, dashicon, textdomain, folderName, editorScript, editorStyle, style, viewStyle, render, viewScriptModule, viewScript, customBlockJSON, example, rootDirectory, } ) { info( '' ); info( 'Creating a "block.json" file.' ); const blockFolderName = plugin ? join( rootDirectory, folderName ) : rootDirectory; await makeDir( blockFolderName ); await writeFile( join( blockFolderName, 'block.json' ), JSON.stringify( Object.fromEntries( Object.entries( { $schema, apiVersion, name: namespace + '/' + slug, version, title, category, icon: dashicon, description, example, attributes, supports, textdomain, editorScript, editorStyle, style, viewStyle, render, viewScriptModule, viewScript, ...customBlockJSON, } ).filter( ( [ , value ] ) => !! value ) ), null, '\t' ) ); } module.exports = async function ( outputTemplates, view ) { await Promise.all( Object.keys( outputTemplates ).map( async ( outputFile ) => { await writeOutputTemplate( outputTemplates[ outputFile ], join( view.plugin ? view.folderName : '', outputFile.replace( /\$slug/g, view.slug ) ), view ); } ) ); await initBlockJSON( view ); };