Setting the file. One moment.
Quick Setup Plan · Rp Setup Discovery · wix/skills · Skills Docs
ContentsBack to the top of the page scripts/quick-setup-plan.js
scripts/ quick-setup-plan.js
JavaScript · 44 lines · 4 KB
)); }
8 async function writeJson ( file , value ) { await fs. mkdir (path. dirname (file), { recursive: true }); await fs. writeFile (file, `${ JSON . stringify ( value , null , 2 ) } \n ` , 'utf8' ); }
9 function envValue ( text , key ) { const match = text. match ( new RegExp ( `^${ key }=(.*)$` , 'm' )); return match ? match[ 1 ]. trim () : null ; }
10 async function siteStrategy ( projectDir ) { try { return envValue ( await fs. readFile (path. join (projectDir, 'config' , 'wix.env' ), 'utf8' ), 'WIX_SITE_STRATEGY' ); } catch (error) { if (error.code === 'ENOENT' ) return null ; throw error; } }
11 function requirementsFor ( plan , strategy ) {
12 const capabilities = new Set (plan.requiredWixCapabilities || []);
13 const hasPosts = (plan.entities || []). some (( entity ) => entity.id === 'post' );
14 const result = [];
15 if (strategy === 'new' ) result. push ({ id: 'mute-site-notifications' , order: 10 , severity: 'blocker' , automation: 'automatable' , expected: 'site notifications are muted' , verification: 'getSiteMuteState returns muted=true' });
16 if (capabilities. has ( 'stores' )) result. push ({ id: 'wix-stores' , order: 20 , severity: 'blocker' , automation: 'automatable' , expected: 'Wix Stores is installed' , verification: 'app installation state is enabled' });
17 if (capabilities. has ( 'stores' ) && strategy === 'existing' ) result. push ({ id: 'stores-catalog-v3' , order: 30 , severity: 'blocker' , automation: 'automatable' , expected: 'catalogVersion is V3_CATALOG' , verification: 'GET /stores/v3/provision/version' });
18 if (capabilities. has ( 'blog' )) result. push ({ id: 'wix-blog' , order: 40 , severity: 'blocker' , automation: 'automatable' , expected: 'Wix Blog is installed' , verification: 'app installation state is enabled' });
19 if (hasPosts) result. push ({ id: 'blog-fallback-author' , order: 50 , severity: 'blocker' , automation: 'automatable' , expected: 'dedicated fallback Blog member exists and WIX_BLOG_FALLBACK_MEMBER_ID is persisted' , verification: 'member lookup and config key status' });
20 return result;
21 }
22 async function main () {
23 const projectDir = process.argv[ 2 ] && path. resolve (process.argv[ 2 ]);
24 if ( ! projectDir) throw new Error ( 'Usage: quick-setup-plan.js <projectDir>' );
25 const plan = await readJson (path. join (projectDir, 'quick-mode' , 'plan.json' ));
26 if (plan.managementImportMode !== 'quick' || ! plan.adapter || ! Array. isArray (plan.entities)) throw new Error ( 'quick-mode/plan.json is not a valid quick plan' );
27 const strategy = await siteStrategy (projectDir);
28 if ( ! strategy) throw new Error ( 'WIX_SITE_STRATEGY is required before quick setup discovery' );
29 const requirements = requirementsFor (plan, strategy);
30 const generatedAt = new Date (). toISOString ();
31 const common = { schemaVersion: 1 , generatedAt, managementImportMode: 'quick' , adapter: plan.adapter, sourcePlan: 'quick-mode/plan.json' , siteStrategy: strategy, requirements };
32 await writeJson (path. join (projectDir, 'setup' , 'setup-plan.json' ), { ... common, steps: requirements. map (( requirement ) => ({ ... requirement, action: requirement.id })) });
33 await writeJson (path. join (projectDir, 'setup' , 'setup-requirements.json' ), common);
34 // setup-blockers.json is no longer seeded here: execute-setup.js is the sole writer of
35 // real blocker content (empty on full success, populated on a genuine failure), so a
36 // permanent blockers:[] stub written before setup ever runs would otherwise let a stale
37 // "no blockers" file survive a later failure. Its absence before setup runs is itself the
38 // correct "setup hasn't run yet" signal.
39 await writeJson (path. join (projectDir, 'setup' , 'llm-handoff.json' ), { schemaVersion: 1 , generatedAt, needsLlm: false , reason: 'Quick setup requirements are derived from the adapter contract.' });
40 await fs. mkdir (path. join (projectDir, 'setup' , 'review' ), { recursive: true });
41 await fs. writeFile (path. join (projectDir, 'setup' , 'review' , 'setup-summary.md' ), `# Quick setup summary \n\n ${ requirements . map (( item ) => `- ${ item . id }: ${ item . expected }` ). join ( ' \n ' ) } \n ` , 'utf8' );
42 console. log ( JSON . stringify ({ ok: true , requirements: requirements. map (( item ) => item.id) }));
43 }
44 main (). catch (( error ) => { console. error (error.message); process. exit ( 1 ); });