Skip to content

Commit aded0e5

Browse files
committed
fix: satisfy canonical import lint gates [AI: OpenAI GPT-5.6 Sol via OpenCode]
1 parent 35f1b33 commit aded0e5

6 files changed

Lines changed: 82 additions & 22 deletions

includes/abilities.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,18 @@ function static_site_importer_register_abilities(): void {
151151
'type' => 'object',
152152
'properties' => array_merge(
153153
array(
154-
'operation' => array( 'type' => 'string', 'enum' => array( 'plan', 'apply' ) ),
154+
'operation' => array(
155+
'type' => 'string',
156+
'enum' => array( 'plan', 'apply' ),
157+
),
155158
'plan' => array( 'type' => 'object' ),
156159
'source' => array(
157160
'type' => 'object',
158161
'properties' => array(
159-
'type' => array( 'type' => 'string', 'enum' => array( 'artifact', 'url', 'upload' ) ),
162+
'type' => array(
163+
'type' => 'string',
164+
'enum' => array( 'artifact', 'url', 'upload' ),
165+
),
160166
'artifact' => array( 'type' => 'object' ),
161167
'url' => array( 'type' => 'string' ),
162168
'import_id' => array( 'type' => 'string' ),
@@ -395,7 +401,7 @@ function static_site_importer_ability_export_theme( array $input ): array {
395401
if ( ! function_exists( 'static_site_importer_ability_import' ) ) {
396402
/** Canonical plan-first import dispatcher. */
397403
function static_site_importer_ability_import( array $input ): array {
398-
$source = isset( $input['source'] ) && is_array( $input['source'] ) ? $input['source'] : array();
404+
$source = isset( $input['source'] ) && is_array( $input['source'] ) ? $input['source'] : array();
399405
$type = (string) ( $source['type'] ?? '' );
400406
$operation = (string) ( $input['operation'] ?? 'apply' );
401407
if ( ! in_array( $operation, array( 'plan', 'apply' ), true ) ) {
@@ -525,9 +531,9 @@ function static_site_importer_ability_import_url_operation( array $input, array
525531
'type' => 'url',
526532
'identity' => hash( 'sha256', (string) wp_json_encode( $terminal['plan'] ) ),
527533
'provenance' => array(
528-
'url' => (string) ( $source['url'] ?? '' ),
529-
'import_id' => (string) ( $result['import_id'] ?? '' ),
530-
'url_batch_run' => $continuation['url_batch_run'],
534+
'url' => (string) ( $source['url'] ?? '' ),
535+
'import_id' => (string) ( $result['import_id'] ?? '' ),
536+
'url_batch_run' => $continuation['url_batch_run'],
531537
),
532538
),
533539
)
@@ -538,7 +544,7 @@ function static_site_importer_ability_import_url_operation( array $input, array
538544
if ( ! function_exists( 'static_site_importer_ability_apply_approved_plan' ) ) {
539545
/** @param array<string,mixed> $input @return array<string,mixed> */
540546
function static_site_importer_ability_apply_approved_plan( array $input ): array {
541-
$plan = $input['plan'];
547+
$plan = $input['plan'];
542548
$receipt = static_site_importer_ability_materialize_wordpress_site_plan( $input );
543549
$success = 'completed' === ( $receipt['status'] ?? '' );
544550

@@ -547,7 +553,10 @@ function static_site_importer_ability_apply_approved_plan( array $input ): array
547553
'operation' => 'apply',
548554
'plan' => $plan,
549555
'result' => $receipt,
550-
'error' => $success ? null : ( $receipt['errors'][0] ?? array( 'code' => 'static_site_importer_materialization_failed', 'message' => 'The approved plan could not be materialized.' ) ),
556+
'error' => $success ? null : ( $receipt['errors'][0] ?? array(
557+
'code' => 'static_site_importer_materialization_failed',
558+
'message' => 'The approved plan could not be materialized.',
559+
) ),
551560
);
552561
}
553562
}

includes/class-static-site-importer-figma-import.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,17 @@ public static function import( array $input ): array {
9292
if ( ! empty( $validation_artifacts ) ) {
9393
$import_input['validation_artifacts'] = $validation_artifacts;
9494
}
95-
$result = static_site_importer_ability_import( array_merge( $import_input, array( 'source' => array( 'type' => 'artifact', 'artifact' => $artifact ) ) ) );
95+
$result = static_site_importer_ability_import(
96+
array_merge(
97+
$import_input,
98+
array(
99+
'source' => array(
100+
'type' => 'artifact',
101+
'artifact' => $artifact,
102+
),
103+
)
104+
)
105+
);
96106
$figma_transform_report = self::figma_transform_report_from_metadata( isset( $import_input['source_metadata'] ) && is_array( $import_input['source_metadata'] ) ? $import_input['source_metadata'] : array() );
97107
if ( ! empty( $figma_transform_report ) ) {
98108
$result['figma_transform_report'] = $figma_transform_report;

includes/class-static-site-importer-theme-generator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ public static function import_website_artifact( array $artifact, array $args = a
4848
$materialization_plan = $compiled_import['materialization_plan'];
4949
$args['font_materialization'] = isset( $materialization_plan['theme']['font_materialization'] ) && is_array( $materialization_plan['theme']['font_materialization'] ) ? $materialization_plan['theme']['font_materialization'] : array();
5050
if ( ! empty( $args['fail_on_quality'] ) && empty( $plan['quality']['pass'] ) ) {
51-
return new WP_Error( 'static_site_importer_quality_gate_failed', 'Website artifact did not pass the canonical plan quality gate.', array( 'quality' => $plan['quality'] ?? array(), 'diagnostics' => $plan['diagnostics'] ?? array() ) );
51+
return new WP_Error(
52+
'static_site_importer_quality_gate_failed',
53+
'Website artifact did not pass the canonical plan quality gate.',
54+
array(
55+
'quality' => $plan['quality'] ?? array(),
56+
'diagnostics' => $plan['diagnostics'] ?? array(),
57+
)
58+
);
5259
}
5360
$lifecycle = self::prepare_wordpress_site_plan_lifecycle( $plan, $args );
5461
if ( is_wp_error( $lifecycle ) ) {

includes/class-static-site-importer-url-batch-import.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,16 +355,18 @@ static function ( string $bytes, array $metadata ): bool {
355355
return self::failed( $run_manifest, $workspace, $manifest, $cursor, $index, $result, $cache );
356356
}
357357
}
358-
$cursor = Static_Site_Importer_Artifact_Batch_Cursor::complete( $cursor, $index );
358+
$cursor = Static_Site_Importer_Artifact_Batch_Cursor::complete( $cursor, $index );
359359
$cursor[ $index ]['result'] = self::result_evidence( $result, $runtime );
360360
$manifest['batches'] = self::legacy_batches( $cursor );
361361
$manifest['diagnostics'] = array_slice( array_merge( $manifest['diagnostics'], $result['import_validation_result']['diagnostics'] ?? array() ), -100 );
362362
if ( is_wp_error( $run_manifest->save( $manifest ) ) ) {
363363
return $run_manifest->save( $manifest );
364-
}// Keep verified prepared input until terminal cleanup for interruption recovery.
364+
}
365+
// Keep verified prepared input until terminal cleanup for interruption recovery.
365366
if ( is_file( $old_cache ) ) {
366367
self::delete_legacy_file( $old_cache );
367-
}++$effective_batches;
368+
}
369+
++$effective_batches;
368370
$final = $result;
369371
unset( $result, $runtime, $raw );
370372
}
@@ -386,7 +388,8 @@ static function ( string $bytes, array $metadata ): bool {
386388
$manifest['final_result'] = $aggregate;
387389
if ( is_wp_error( $run_manifest->save( $manifest ) ) ) {
388390
return $run_manifest->save( $manifest );
389-
}return $aggregate;
391+
}
392+
return $aggregate;
390393
}
391394
/**
392395
* Persist the Blocks Engine staged envelopes. The shared envelope is created
@@ -463,7 +466,7 @@ private static function compose_staged_plans( array $staged ): array|WP_Error {
463466
* @return array<string,mixed>|WP_Error
464467
*/
465468
private static function compose_complete_plan( Static_Site_Importer_Artifact_Run_Workspace $workspace, array $cursor ): array|WP_Error {
466-
$shared_raw = $workspace->read_raw( 'staged-compiler-shared.json' );
469+
$shared_raw = $workspace->read_raw( 'staged-compiler-shared.json' );
467470
$shared_state = is_string( $shared_raw ) ? json_decode( $shared_raw, true ) : null;
468471
$shared_plan = is_array( $shared_state ) && is_array( $shared_state['plan'] ?? null ) ? $shared_state['plan'] : null;
469472
if ( ! is_array( $shared_plan ) ) {
@@ -506,7 +509,7 @@ private static function compose_complete_plan( Static_Site_Importer_Artifact_Run
506509
'quality' => is_array( $plan['quality'] ?? null ) ? $plan['quality'] : array(),
507510
'diagnostics' => is_array( $plan['diagnostics'] ?? null ) ? $plan['diagnostics'] : array(),
508511
'provenance' => array(
509-
'snapshot_identity' => hash( 'sha256', wp_json_encode( $snapshots ) ),
512+
'snapshot_identity' => hash( 'sha256', (string) wp_json_encode( $snapshots ) ),
510513
'snapshots' => $snapshots,
511514
),
512515
);

includes/rest.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,19 @@ function static_site_importer_rest_import_figma_file( WP_REST_Request $request )
170170
if ( static_site_importer_rest_should_apply_to_current_site( $request->get_params() ) ) {
171171
$input['activate'] = ! empty( $request->get_param( 'activate' ) );
172172
$input['overwrite'] = ! empty( $request->get_param( 'overwrite' ) );
173-
$result = static_site_importer_rest_execute_import_ability( 'static-site-importer/import', array_merge( $input, array( 'source' => array( 'type' => 'artifact', 'artifact' => $artifact ) ) ), 'static_site_importer_ability_import' );
173+
$result = static_site_importer_rest_execute_import_ability(
174+
'static-site-importer/import',
175+
array_merge(
176+
$input,
177+
array(
178+
'source' => array(
179+
'type' => 'artifact',
180+
'artifact' => $artifact,
181+
),
182+
)
183+
),
184+
'static_site_importer_ability_import'
185+
);
174186
if ( is_wp_error( $result ) ) {
175187
return $result;
176188
}
@@ -572,7 +584,10 @@ function static_site_importer_rest_open_in_playground( array $source, array $inp
572584
}
573585
$input['source_metadata'] = $source_metadata;
574586
$input['artifact'] = $artifact;
575-
$input['source'] = array( 'type' => 'artifact', 'artifact' => $artifact );
587+
$input['source'] = array(
588+
'type' => 'artifact',
589+
'artifact' => $artifact,
590+
);
576591

577592
$identity = Static_Site_Importer_Site_Identity::resolve(
578593
array(
@@ -709,7 +724,10 @@ function static_site_importer_rest_apply_to_current_site( array $source, array $
709724
$source_metadata['url_import_provider'] = (string) $runtime['provider'];
710725
}
711726
$input['source_metadata'] = $source_metadata;
712-
$input['source'] = array( 'type' => 'artifact', 'artifact' => $runtime['artifact'] );
727+
$input['source'] = array(
728+
'type' => 'artifact',
729+
'artifact' => $runtime['artifact'],
730+
);
713731

714732
return $decorate_current_site_preview( static_site_importer_rest_execute_import_ability( 'static-site-importer/import', $input, 'static_site_importer_ability_import' ) );
715733
}

static-site-importer.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,17 @@ static function ( array $args, array $assoc_args ): void {
213213
'asset_materialization_policy' => isset( $assoc_args['asset-materialization-policy'] ) ? (string) $assoc_args['asset-materialization-policy'] : '',
214214
);
215215

216-
$result = static_site_importer_ability_import( array_merge( $input, array( 'source' => array( 'type' => 'artifact', 'artifact' => $input['artifact'] ) ) ) );
216+
$result = static_site_importer_ability_import(
217+
array_merge(
218+
$input,
219+
array(
220+
'source' => array(
221+
'type' => 'artifact',
222+
'artifact' => $input['artifact'],
223+
),
224+
)
225+
)
226+
);
217227
if ( empty( $result['success'] ) ) {
218228
$error = isset( $result['error'] ) && is_array( $result['error'] ) ? $result['error'] : array();
219229
WP_CLI::error( (string) ( $error['message'] ?? 'Static site import failed.' ) );
@@ -232,7 +242,10 @@ static function ( array $args, array $assoc_args ): void {
232242
}
233243

234244
$input = array(
235-
'source' => array( 'type' => 'url', 'url' => $url ),
245+
'source' => array(
246+
'type' => 'url',
247+
'url' => $url,
248+
),
236249
'slug' => isset( $assoc_args['slug'] ) ? (string) $assoc_args['slug'] : '',
237250
'name' => isset( $assoc_args['name'] ) ? (string) $assoc_args['name'] : '',
238251
'site_title' => isset( $assoc_args['site-title'] ) ? (string) $assoc_args['site-title'] : '',
@@ -246,7 +259,7 @@ static function ( array $args, array $assoc_args ): void {
246259
$result = static_site_importer_ability_import( $input );
247260
while ( ! empty( $result['success'] ) && ! empty( $result['continuation'] ) ) {
248261
$input['source']['import_id'] = (string) ( $result['import_id'] ?? '' );
249-
$result = static_site_importer_ability_import( $input );
262+
$result = static_site_importer_ability_import( $input );
250263
}
251264
if ( empty( $result['success'] ) ) {
252265
$error = isset( $result['error'] ) && is_array( $result['error'] ) ? $result['error'] : array();

0 commit comments

Comments
 (0)