@slicemachine/manager 0.25.7-alpha.jp-figma-to-slice-1.2 → 0.25.7-alpha.jp-figma-to-slice-1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/managers/customTypes/CustomTypesManager.cjs +187 -156
- package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.js +190 -159
- package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
- package/package.json +2 -2
- package/src/managers/customTypes/CustomTypesManager.ts +212 -164
|
@@ -17,6 +17,7 @@ const crypto = require("node:crypto");
|
|
|
17
17
|
const path = require("node:path");
|
|
18
18
|
const fs = require("node:fs/promises");
|
|
19
19
|
const claudeAgentSdk = require("@anthropic-ai/claude-agent-sdk");
|
|
20
|
+
const APPLICATION_MODE = require("../../constants/APPLICATION_MODE.cjs");
|
|
20
21
|
function _interopNamespaceDefault(e) {
|
|
21
22
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
22
23
|
if (e) {
|
|
@@ -312,6 +313,7 @@ class CustomTypesManager extends BaseManager.BaseManager {
|
|
|
312
313
|
throw new Error("User does not have access to the LLM proxy.");
|
|
313
314
|
}
|
|
314
315
|
const { llmProxyUrl } = index.default.object({ llmProxyUrl: index.default.string().url() }).parse(exp.payload);
|
|
316
|
+
console.info({ llmProxyUrl });
|
|
315
317
|
let tmpDir;
|
|
316
318
|
try {
|
|
317
319
|
const config = await this.project.getSliceMachineConfig();
|
|
@@ -326,176 +328,197 @@ class CustomTypesManager extends BaseManager.BaseManager {
|
|
|
326
328
|
if (!framework) {
|
|
327
329
|
throw new Error("Could not determine framework from Slice Machine config.");
|
|
328
330
|
}
|
|
329
|
-
let frameworkFileExtension;
|
|
330
|
-
if (framework.type === "nextjs") {
|
|
331
|
-
frameworkFileExtension = "tsx";
|
|
332
|
-
} else if (framework.type === "nuxt") {
|
|
333
|
-
frameworkFileExtension = "vue";
|
|
334
|
-
} else if (framework.type === "sveltekit") {
|
|
335
|
-
frameworkFileExtension = "svelte";
|
|
336
|
-
}
|
|
337
|
-
if (!frameworkFileExtension) {
|
|
338
|
-
throw new Error("Could not determine framework from Slice Machine config.");
|
|
339
|
-
}
|
|
340
331
|
const projectRoot = await this.project.getRoot();
|
|
341
332
|
const libraryAbsPath = path.join(projectRoot, libraryID);
|
|
333
|
+
const cwd = libraryAbsPath;
|
|
342
334
|
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "slice-machine-infer-slice-tmp-"));
|
|
343
|
-
const
|
|
335
|
+
const tmpImageAbsPath = path.join(tmpDir, `${crypto.randomUUID()}.png`);
|
|
344
336
|
const response = await fetch.default(imageUrl);
|
|
345
337
|
if (!response.ok) {
|
|
346
338
|
throw new Error(`Failed to download image: ${response.status} ${response.statusText}`);
|
|
347
339
|
}
|
|
348
|
-
await fs.writeFile(
|
|
340
|
+
await fs.writeFile(tmpImageAbsPath, Buffer.from(await response.arrayBuffer()));
|
|
341
|
+
const otherSlices = (await Promise.all((await fs.readdir(libraryAbsPath, { withFileTypes: true })).flatMap(async (path$1) => {
|
|
342
|
+
try {
|
|
343
|
+
if (!path$1.isDirectory()) {
|
|
344
|
+
throw new Error("Not a directory");
|
|
345
|
+
}
|
|
346
|
+
const absPath = path.join(libraryAbsPath, path$1.name);
|
|
347
|
+
const modelAbsPath = path.join(absPath, "model.json");
|
|
348
|
+
if (!node_fs.existsSync(modelAbsPath)) {
|
|
349
|
+
throw new Error("Model file not found");
|
|
350
|
+
}
|
|
351
|
+
const decoded = customtypes.SharedSlice.decode(JSON.parse(await fs.readFile(modelAbsPath, "utf-8")));
|
|
352
|
+
if (decoded._tag === "Left") {
|
|
353
|
+
throw new Error("Invalid model file");
|
|
354
|
+
}
|
|
355
|
+
return [
|
|
356
|
+
{
|
|
357
|
+
absPath,
|
|
358
|
+
relPath: path.relative(cwd, absPath),
|
|
359
|
+
name: decoded.right.name
|
|
360
|
+
}
|
|
361
|
+
];
|
|
362
|
+
} catch {
|
|
363
|
+
return [];
|
|
364
|
+
}
|
|
365
|
+
}))).flat();
|
|
366
|
+
const prompt = `CRITICAL INSTRUCTIONS - READ FIRST:
|
|
367
|
+
- You MUST start immediately with Step 1.1. DO NOT read, analyze, or explore any project files first.
|
|
368
|
+
- Work step-by-step through the numbered tasks below.
|
|
369
|
+
- DO NOT present any summary, explanation, or completion message after finishing.
|
|
370
|
+
- DO NOT create TODO lists while performing tasks.
|
|
371
|
+
- Keep responses minimal - only show necessary tool calls and brief progress notes.
|
|
372
|
+
|
|
373
|
+
# CONTEXT
|
|
374
|
+
|
|
375
|
+
The user wants to build a new Prismic Slice based on a design image they provided.
|
|
376
|
+
Your goal is to analyze the design image and generate the JSON model data and boilerplate code for the slice following Prismic requirements.
|
|
377
|
+
|
|
378
|
+
You will work under the slice library at <slice_library_directory_path>, where all the slices are stored.
|
|
379
|
+
|
|
380
|
+
# AVAILABLE RESOURCES
|
|
381
|
+
|
|
382
|
+
<framework>
|
|
383
|
+
${framework.label}
|
|
384
|
+
</framework>
|
|
385
|
+
|
|
386
|
+
<design_image_path>
|
|
387
|
+
${tmpImageAbsPath}
|
|
388
|
+
</design_image_path>
|
|
389
|
+
|
|
390
|
+
<slice_library_directory_path>
|
|
391
|
+
${libraryAbsPath}
|
|
392
|
+
</slice_library_directory_path>
|
|
393
|
+
|
|
394
|
+
<disallowed_slice_names>
|
|
395
|
+
${otherSlices.map((slice) => `- ${slice.name}`).join("\n")}
|
|
396
|
+
</disallowed_slice_names>
|
|
397
|
+
|
|
398
|
+
# AVAILABLE TOOLS
|
|
399
|
+
|
|
400
|
+
You have access to specialized Prismic MCP tools for this task:
|
|
401
|
+
|
|
402
|
+
<tool name="mcp__prismic__how_to_model_slice">
|
|
403
|
+
<description>
|
|
404
|
+
Provides detailed guidance on creating Prismic slice models, including field types, naming conventions, and best practices.
|
|
405
|
+
</description>
|
|
406
|
+
<when_to_use>
|
|
407
|
+
Call this tool in Step 2.1 to learn how to structure the slice model data for the design you analysed.
|
|
408
|
+
</when_to_use>
|
|
409
|
+
</tool>
|
|
410
|
+
|
|
411
|
+
<tool name="mcp__prismic__how_to_code_slice">
|
|
412
|
+
<description>
|
|
413
|
+
Provides guidance on implementing Prismic slice components, including how to use Prismic field components, props structure, and best practices.
|
|
414
|
+
</description>
|
|
415
|
+
<when_to_use>
|
|
416
|
+
Call this tool in Step 2.1 to learn how to properly structure the slice component with Prismic fields.
|
|
417
|
+
</when_to_use>
|
|
418
|
+
</tool>
|
|
419
|
+
|
|
420
|
+
<tool name="mcp__prismic__save_slice_data">
|
|
421
|
+
<description>
|
|
422
|
+
Validates and saves the slice model data to model.json. This is the ONLY way to create the model file.
|
|
423
|
+
</description>
|
|
424
|
+
<when_to_use>
|
|
425
|
+
Call this tool in Step 2.3 after you have built the complete slice model structure in memory.
|
|
426
|
+
</when_to_use>
|
|
427
|
+
</tool>
|
|
428
|
+
|
|
429
|
+
# TASK REQUIREMENTS
|
|
430
|
+
|
|
431
|
+
## Step 1: Gather information from the design image
|
|
432
|
+
1.1. Analyse the design image at <design_image_path>.
|
|
433
|
+
1.2. Identify all elements in the image that should be dynamically editable (e.g., headings, paragraphs, images, links, buttons, etc.).
|
|
434
|
+
1.3. Come up with a UNIQUE name for the new slice based on the content of the image, DO NOT use any of the names in <disallowed_slice_names>.
|
|
435
|
+
|
|
436
|
+
## Step 2: Model the Prismic slice
|
|
437
|
+
2.1. Call mcp__prismic__how_to_model_slice to learn how to structure the model for this design.
|
|
438
|
+
2.2. Build the complete slice JSON model data in memory based on the guidance received and the information extracted from the image.
|
|
439
|
+
2.3. Call mcp__prismic__save_slice_data to save the model (DO NOT manually write model.json) in the slice library at <slice_library_directory_path>.
|
|
440
|
+
|
|
441
|
+
## Step 3: Code a boilerplate slice component based on the model
|
|
442
|
+
3.1. Call mcp__prismic__how_to_code_slice to learn how to properly structure the slice component with Prismic fields.
|
|
443
|
+
3.2. Update the slice component code at <slice_library_directory_path>/index.*, replacing the placeholder code with boilerplate code with the following requirements:
|
|
444
|
+
- Must NOT be based on existing slices or components from the codebase.
|
|
445
|
+
- Must render all the Prismic components to display the fields of the slice model created at <slice_model_path>.
|
|
446
|
+
- Must be a valid ${framework.label} component.
|
|
447
|
+
- Must NOT have any styling/CSS. No inlines styles or classNames. Just the skeleton component structure.
|
|
448
|
+
- Must NOT use any other custom component or functions from the user's codebase.
|
|
449
|
+
- Avoid creating unnecessary wrapper elements, like if they only wrap a single component (e.g., <div><PrismicRichText /></div>).
|
|
450
|
+
|
|
451
|
+
## Step 4: Present the newly created slice path
|
|
452
|
+
4.1. Present the path to the newly created slice in the following format: <new_slice_path>${libraryAbsPath}/MyNewSlice</new_slice_path>.
|
|
453
|
+
- "MyNewSlice" must be the name of the directory of the newly created slice.
|
|
454
|
+
|
|
455
|
+
# EXAMPLE OF CORRECT EXECUTION
|
|
456
|
+
|
|
457
|
+
<example>
|
|
458
|
+
Assistant: Step 1.1: Analysing design image...
|
|
459
|
+
[reads <design_image_path>]
|
|
460
|
+
|
|
461
|
+
Step 1.2: Identifying editable content elements...
|
|
462
|
+
[identifies: title field, description field, buttonText field, buttonLink field, backgroundImage field]
|
|
463
|
+
|
|
464
|
+
Step 1.3: Listing slice directories under <slice_library_directory_path>...
|
|
465
|
+
[lists slice directories: Hero, Hero2, Hero3]
|
|
466
|
+
|
|
467
|
+
Step 1.4: Coming up with a unique name for the new slice...
|
|
468
|
+
[comes up with a unique name for the new slice: Hero4]
|
|
469
|
+
|
|
470
|
+
Step 2.1: Getting Prismic modeling guidance...
|
|
471
|
+
[calls mcp__prismic__how_to_model_slice]
|
|
472
|
+
|
|
473
|
+
Step 2.2: Building slice model based on guidance and the information extracted...
|
|
474
|
+
[creates model with title field, description field, buttonText field, buttonLink field, backgroundImage field]
|
|
475
|
+
|
|
476
|
+
Step 2.3: Saving slice model...
|
|
477
|
+
[calls mcp__prismic__save_slice_data]
|
|
478
|
+
|
|
479
|
+
Step 3.1: Learning Prismic slice coding requirements...
|
|
480
|
+
[calls mcp__prismic__how_to_code_slice]
|
|
481
|
+
|
|
482
|
+
Step 3.2: Coding boilerplate slice component based on the model...
|
|
483
|
+
[updates component with Prismic field components, no styling, no other components]
|
|
484
|
+
|
|
485
|
+
Step 4.1: Presenting the path to the newly created slice...
|
|
486
|
+
[presents <new_slice_path>${path.join(libraryAbsPath, "MyNewSlice")}</new_slice_path>]
|
|
487
|
+
|
|
488
|
+
# DELIVERABLES
|
|
489
|
+
- Slice model saved to <slice_library_directory_path>/model.json using mcp__prismic__save_slice_data
|
|
490
|
+
- Slice component at <slice_library_directory_path>/index.* updated with boilerplate code
|
|
491
|
+
- New slice path presented in the format mentioned in Step 3.1
|
|
492
|
+
|
|
493
|
+
YOU ARE NOT FINISHED UNTIL YOU HAVE THESE DELIVERABLES.
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
FINAL REMINDERS:
|
|
498
|
+
- You MUST use mcp__prismic__save_slice_data to save the model
|
|
499
|
+
- You MUST call mcp__prismic__how_to_code_slice in Step 3.1
|
|
500
|
+
- DO NOT ATTEMPT TO BUILD THE APPLICATION
|
|
501
|
+
- START IMMEDIATELY WITH STEP 1.1 - NO PRELIMINARY ANALYSIS`;
|
|
349
502
|
const queries = claudeAgentSdk.query({
|
|
350
|
-
prompt
|
|
351
|
-
- You MUST start immediately with Step 1.1. DO NOT read, analyze, or explore any project files first.
|
|
352
|
-
- Work step-by-step through the numbered tasks below.
|
|
353
|
-
- DO NOT present any summary, explanation, or completion message after finishing.
|
|
354
|
-
- DO NOT create TODO lists while performing tasks.
|
|
355
|
-
- Keep responses minimal - only show necessary tool calls and brief progress notes.
|
|
356
|
-
|
|
357
|
-
# CONTEXT
|
|
358
|
-
|
|
359
|
-
The user wants to build a new Prismic Slice based on a design image they provided.
|
|
360
|
-
Your goal is to analyze the design image and generate the JSON model data and boilerplate code for the slice following Prismic requirements.
|
|
361
|
-
|
|
362
|
-
You will work under the slice library at <slice_library_path>, where all the slices are stored.
|
|
363
|
-
|
|
364
|
-
# AVAILABLE RESOURCES
|
|
365
|
-
|
|
366
|
-
<design_image_path>
|
|
367
|
-
${tmpImagePath}
|
|
368
|
-
</design_image_path>
|
|
369
|
-
|
|
370
|
-
<slice_library_path>
|
|
371
|
-
${libraryAbsPath}
|
|
372
|
-
</slice_library_path>
|
|
373
|
-
|
|
374
|
-
<framework>
|
|
375
|
-
${framework.label}
|
|
376
|
-
</framework>
|
|
377
|
-
|
|
378
|
-
# AVAILABLE TOOLS
|
|
379
|
-
|
|
380
|
-
You have access to specialized Prismic MCP tools for this task:
|
|
381
|
-
|
|
382
|
-
<tool name="mcp__prismic__how_to_model_slice">
|
|
383
|
-
<description>
|
|
384
|
-
Provides detailed guidance on creating Prismic slice models, including field types, naming conventions, and best practices.
|
|
385
|
-
</description>
|
|
386
|
-
<when_to_use>
|
|
387
|
-
Call this tool in Step 2.1 to learn how to structure the slice model data for the design you analysed.
|
|
388
|
-
</when_to_use>
|
|
389
|
-
</tool>
|
|
390
|
-
|
|
391
|
-
<tool name="mcp__prismic__how_to_code_slice">
|
|
392
|
-
<description>
|
|
393
|
-
Provides guidance on implementing Prismic slice components, including how to use Prismic field components, props structure, and best practices.
|
|
394
|
-
</description>
|
|
395
|
-
<when_to_use>
|
|
396
|
-
Call this tool in Step 2.1 to learn how to properly structure the slice component with Prismic fields.
|
|
397
|
-
</when_to_use>
|
|
398
|
-
</tool>
|
|
399
|
-
|
|
400
|
-
<tool name="mcp__prismic__save_slice_data">
|
|
401
|
-
<description>
|
|
402
|
-
Validates and saves the slice model data to model.json. This is the ONLY way to create the model file.
|
|
403
|
-
</description>
|
|
404
|
-
<when_to_use>
|
|
405
|
-
Call this tool in Step 2.3 after you have built the complete slice model structure in memory.
|
|
406
|
-
</when_to_use>
|
|
407
|
-
</tool>
|
|
408
|
-
|
|
409
|
-
# TASK REQUIREMENTS
|
|
410
|
-
|
|
411
|
-
## Step 1: Gather information from the design image
|
|
412
|
-
1.1. Analyse the design image at <design_image_path>.
|
|
413
|
-
1.2. Identify all elements in the image that should be dynamically editable (e.g., headings, paragraphs, images, links, buttons, etc.).
|
|
414
|
-
1.3. List the slice directories under <slice_library_path>.
|
|
415
|
-
1.4. Come up with a unique name for the new slice based on the content of the image and the slice directories.
|
|
416
|
-
|
|
417
|
-
## Step 2: Model the Prismic slice
|
|
418
|
-
2.1. Call mcp__prismic__how_to_model_slice to learn how to structure the model for this design.
|
|
419
|
-
- Make sure the name you use for the new slice does not yet exist in the slice library at <slice_library_path>. If it does, use a different name.
|
|
420
|
-
2.2. Build the complete slice JSON model data in memory based on the guidance received and the information extracted from the image.
|
|
421
|
-
2.3. Call mcp__prismic__save_slice_data to save the model (DO NOT manually write model.json) in the slice library at <slice_library_path>.
|
|
422
|
-
|
|
423
|
-
## Step 3: Code a boilerplate slice component based on the model
|
|
424
|
-
3.1. Call mcp__prismic__how_to_code_slice to learn how to properly structure the slice component with Prismic fields.
|
|
425
|
-
3.2. Update the slice component code at <slice_library_path>/index.${frameworkFileExtension}, replacing the placeholder code with boilerplate code with the following requirements:
|
|
426
|
-
- Must NOT be based on existing slices or components from the codebase.
|
|
427
|
-
- Must render all the Prismic components to display the fields of the slice model created at <slice_model_path>.
|
|
428
|
-
- Must be a valid ${framework.label} component.
|
|
429
|
-
- Must NOT have any styling/CSS. No inlines styles or classNames. Just the skeleton component structure.
|
|
430
|
-
- Must NOT use any other custom component or functions from the user's codebase.
|
|
431
|
-
- Avoid creating unnecessary wrapper elements, like if they only wrap a single component (e.g., <div><PrismicRichText /></div>).
|
|
432
|
-
|
|
433
|
-
## Step 4: Present the newly created slice path
|
|
434
|
-
4.1. Present the path to the newly created slice in the following format: <new_slice_path>${libraryAbsPath}/MyNewSlice</new_slice_path>.
|
|
435
|
-
- "MyNewSlice" must be the name of the directory of the newly created slice.
|
|
436
|
-
|
|
437
|
-
# EXAMPLE OF CORRECT EXECUTION
|
|
438
|
-
|
|
439
|
-
<example>
|
|
440
|
-
Assistant: Step 1.1: Analysing design image...
|
|
441
|
-
[reads <design_image_path>]
|
|
442
|
-
|
|
443
|
-
Step 1.2: Identifying editable content elements...
|
|
444
|
-
[identifies: title field, description field, buttonText field, buttonLink field, backgroundImage field]
|
|
445
|
-
|
|
446
|
-
Step 1.3: Listing slice directories under <slice_library_path>...
|
|
447
|
-
[lists slice directories: Hero, Hero2, Hero3]
|
|
448
|
-
|
|
449
|
-
Step 1.4: Coming up with a unique name for the new slice...
|
|
450
|
-
[comes up with a unique name for the new slice: Hero4]
|
|
451
|
-
|
|
452
|
-
Step 2.1: Getting Prismic modeling guidance...
|
|
453
|
-
[calls mcp__prismic__how_to_model_slice]
|
|
454
|
-
|
|
455
|
-
Step 2.2: Building slice model based on guidance and the information extracted...
|
|
456
|
-
[creates model with title field, description field, buttonText field, buttonLink field, backgroundImage field]
|
|
457
|
-
|
|
458
|
-
Step 2.3: Saving slice model...
|
|
459
|
-
[calls mcp__prismic__save_slice_data]
|
|
460
|
-
|
|
461
|
-
Step 3.1: Learning Prismic slice coding requirements...
|
|
462
|
-
[calls mcp__prismic__how_to_code_slice]
|
|
463
|
-
|
|
464
|
-
Step 3.2: Coding boilerplate slice component based on the model...
|
|
465
|
-
[updates component with Prismic field components, no styling, no other components]
|
|
466
|
-
|
|
467
|
-
Step 4.1: Presenting the path to the newly created slice...
|
|
468
|
-
[presents <new_slice_path>${path.join(libraryAbsPath, "MyNewSlice")}</new_slice_path>]
|
|
469
|
-
|
|
470
|
-
# DELIVERABLES
|
|
471
|
-
- Slice model saved to <slice_library_path>/model.json using mcp__prismic__save_slice_data
|
|
472
|
-
- Slice component at <slice_library_path>/index.${frameworkFileExtension} updated with boilerplate code
|
|
473
|
-
- New slice path presented in the format mentioned in Step 3.1
|
|
474
|
-
|
|
475
|
-
YOU ARE NOT FINISHED UNTIL YOU HAVE THESE DELIVERABLES.
|
|
476
|
-
|
|
477
|
-
---
|
|
478
|
-
|
|
479
|
-
FINAL REMINDERS:
|
|
480
|
-
- You MUST use mcp__prismic__save_slice_data to save the model
|
|
481
|
-
- You MUST call mcp__prismic__how_to_code_slice in Step 3.1
|
|
482
|
-
- DO NOT ATTEMPT TO BUILD THE APPLICATION
|
|
483
|
-
- START IMMEDIATELY WITH STEP 1.1 - NO PRELIMINARY ANALYSIS;`,
|
|
503
|
+
prompt,
|
|
484
504
|
options: {
|
|
485
|
-
cwd
|
|
486
|
-
stderr: (data) =>
|
|
505
|
+
cwd,
|
|
506
|
+
stderr: (data) => {
|
|
507
|
+
if (!data.startsWith("Spawning Claude Code process")) {
|
|
508
|
+
console.error("inferSlice error:" + data);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
487
511
|
model: "claude-haiku-4-5",
|
|
488
|
-
permissionMode: "
|
|
512
|
+
permissionMode: "acceptEdits",
|
|
489
513
|
allowedTools: [
|
|
490
|
-
|
|
514
|
+
`Bash(${cwd})`,
|
|
491
515
|
"Read",
|
|
492
|
-
"FileSearch",
|
|
493
516
|
"Grep",
|
|
494
517
|
"Glob",
|
|
495
|
-
"Task",
|
|
496
|
-
"Edit",
|
|
497
518
|
"Write",
|
|
519
|
+
"Edit",
|
|
498
520
|
"MultiEdit",
|
|
521
|
+
"FileSearch",
|
|
499
522
|
"mcp__prismic__how_to_model_slice",
|
|
500
523
|
"mcp__prismic__how_to_code_slice",
|
|
501
524
|
"mcp__prismic__save_slice_data"
|
|
@@ -504,7 +527,12 @@ class CustomTypesManager extends BaseManager.BaseManager {
|
|
|
504
527
|
`Edit(**/model.json)`,
|
|
505
528
|
`Write(**/model.json)`,
|
|
506
529
|
"Edit(**/mocks.json)",
|
|
507
|
-
"Write(**/mocks.json)"
|
|
530
|
+
"Write(**/mocks.json)",
|
|
531
|
+
...otherSlices.flatMap((slice) => [
|
|
532
|
+
`Write(${slice.relPath})`,
|
|
533
|
+
`Edit(${slice.relPath})`,
|
|
534
|
+
`MultiEdit(${slice.relPath})`
|
|
535
|
+
])
|
|
508
536
|
],
|
|
509
537
|
env: {
|
|
510
538
|
...process.env,
|
|
@@ -524,6 +552,9 @@ x-prismic-repository: ${repository}
|
|
|
524
552
|
});
|
|
525
553
|
let newSliceAbsPath;
|
|
526
554
|
for await (const query of queries) {
|
|
555
|
+
if (process.env.SM_ENV !== APPLICATION_MODE.APPLICATION_MODE.Production) {
|
|
556
|
+
console.info(JSON.stringify(query, null, 2));
|
|
557
|
+
}
|
|
527
558
|
switch (query.type) {
|
|
528
559
|
case "result":
|
|
529
560
|
if (query.subtype === "success") {
|
|
@@ -539,7 +570,7 @@ x-prismic-repository: ${repository}
|
|
|
539
570
|
if (!model) {
|
|
540
571
|
throw new Error("Could not find model for the newly created slice.");
|
|
541
572
|
}
|
|
542
|
-
await fs.rename(
|
|
573
|
+
await fs.rename(tmpImageAbsPath, path.join(newSliceAbsPath, "screenshot-default.png"));
|
|
543
574
|
return InferSliceResponse.parse({ slice: JSON.parse(model) });
|
|
544
575
|
} finally {
|
|
545
576
|
if (tmpDir && node_fs.existsSync(tmpDir)) {
|