soinproduction-gutenberg 0.1.0 → 0.1.1
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.
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {execFileSync} from 'node:child_process';
|
|
5
|
+
const temporary=fs.mkdtempSync(path.join(os.tmpdir(),'kit-packed-'));
|
|
6
|
+
try{
|
|
7
|
+
const root=process.cwd();
|
|
8
|
+
const archive=execFileSync('npm',['pack','--ignore-scripts','--silent','--pack-destination',temporary],{cwd:root,encoding:'utf8'}).trim().split('\n').at(-1);
|
|
9
|
+
const consumer=path.join(temporary,'consumer');fs.mkdirSync(consumer);
|
|
10
|
+
fs.writeFileSync(path.join(consumer,'package.json'),JSON.stringify({name:'kit-smoke-consumer',version:'1.0.0',private:true,type:'module'}));
|
|
11
|
+
execFileSync('npm',['install',path.join(temporary,archive),'--ignore-scripts','--no-audit','--no-fund'],{cwd:consumer,stdio:'pipe',env:{...process.env,npm_config_userconfig:os.devNull}});
|
|
12
|
+
execFileSync(process.execPath,['--input-type=module','-e',"import {Background,Heading,Drag} from 'soinproduction-gutenberg'; if([Background,Heading,Drag].some(value=>typeof value!=='function'))throw new Error('Missing public exports');"],{cwd:consumer,stdio:'pipe'});
|
|
13
|
+
fs.mkdirSync(path.join(consumer,'config'));fs.mkdirSync(path.join(consumer,'src/sections/section-example'),{recursive:true});
|
|
14
|
+
fs.writeFileSync(path.join(consumer,'tsconfig.json'),JSON.stringify({compilerOptions:{paths:{'@kit':['./kit/index.tsx'],'@kit/*':['./kit/*']}}}));
|
|
15
|
+
fs.writeFileSync(path.join(consumer,'kit.config.json'),JSON.stringify({modules:[]}));
|
|
16
|
+
fs.writeFileSync(path.join(consumer,'config/breakpoints.json'),JSON.stringify({breakpoints:{mobile:480,tablet:768},media:{columns:'tablet'},layoutIgnore:[]}));
|
|
17
|
+
fs.writeFileSync(path.join(consumer,'src/sections/section-example/section.json'),JSON.stringify({slug:'section-example',title:'Example'}));
|
|
18
|
+
fs.writeFileSync(path.join(consumer,'src/sections/section-example/section.tsx'),"import {Background,Heading,Section,section} from '@kit';export default section({slug:'example',title:'Example'},()=> <Section><Background name='background'/><Heading name='heading'/></Section>);");
|
|
19
|
+
execFileSync(process.execPath,['node_modules/.bin/soinproduction-kit','prepare'],{cwd:consumer,stdio:'pipe'});
|
|
20
|
+
const connections=JSON.parse(fs.readFileSync(path.join(consumer,'kit/generated/connections.json'),'utf8'));
|
|
21
|
+
if(!connections.components.includes('background'))throw new Error('Installed package did not connect Background');
|
|
22
|
+
execFileSync(process.execPath,['--input-type=module','-e',"import {buildSync} from 'esbuild';buildSync({entryPoints:['src/sections/section-example/section.tsx'],bundle:true,write:false,platform:'node',format:'esm',packages:'external',jsx:'automatic',tsconfig:'tsconfig.json'});"],{cwd:consumer,stdio:'pipe'});
|
|
23
|
+
if(!fs.existsSync(path.join(consumer,'node_modules/soinproduction-gutenberg/dist/components/forms/server.php')))throw new Error('Missing packaged server files');
|
|
24
|
+
console.log('Packed npm installation, public ESM exports, PHP assets and host preparation verified in a clean consumer.');
|
|
25
|
+
}catch(error){if(error.stdout)console.error(String(error.stdout));if(error.stderr)console.error(String(error.stderr));throw error;}finally{fs.rmSync(temporary,{recursive:true,force:true});}
|