@platforma-sdk/block-tools 2.17.6 → 2.17.8
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/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +800 -792
- package/dist/cli.mjs.map +1 -1
- package/dist/structure/__tests__/tool-bin.d.ts +4 -0
- package/dist/structure/cli/run-structure.d.ts +6 -0
- package/package.json +13 -12
- package/src/cmd/structure/check.ts +8 -3
- package/src/cmd/structure/refresh.ts +6 -2
- package/src/structure/__tests__/init-lint-clean.test.ts +9 -8
- package/src/structure/__tests__/oxfmt-clean-init.test.ts +8 -7
- package/src/structure/__tests__/root-catalog-bump.test.ts +3 -6
- package/src/structure/__tests__/root-catalog-floor.test.ts +107 -0
- package/src/structure/__tests__/tool-bin.ts +41 -0
- package/src/structure/cli/run-structure.ts +17 -0
- package/src/structure/rules/root-catalog-bump.ts +6 -7
- package/src/structure/rules/root-package-json.ts +12 -7
- package/src/structure/rules/root-pnpm-workspace.ts +13 -0
package/dist/cli.js
CHANGED
|
@@ -6,23 +6,23 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
6
6
|
`)+`
|
|
7
7
|
`+` `.repeat(t)+`}`}return JSON.stringify(e)}function Be(e,t){return t?.collapse?ze(JSON.parse(JSON.stringify(e??null)),0,0,0)+`
|
|
8
8
|
`:JSON.stringify(e,null,2)+`
|
|
9
|
-
`}function Ve(e){return e===``||e===void 0?[]:e.split(`.`)}function O(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function He(e,t){let n=Ve(t),r=e;for(let e of n){if(!O(r))return;r=r[e]}return r}function
|
|
10
|
-
`);return t.length>0&&t[t.length-1]===``&&t.pop(),t}function
|
|
9
|
+
`}function Ve(e){return e===``||e===void 0?[]:e.split(`.`)}function O(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function He(e,t){let n=Ve(t),r=e;for(let e of n){if(!O(r))return;r=r[e]}return r}function k(e,t){let n=Ve(t);if(n.length===0)return!0;let r=e;for(let e=0;e<n.length-1;e++){if(!O(r))return!1;r=r[n[e]]}return O(r)?n[n.length-1]in r:!1}function Ue(e,t,n){let r=Ve(t);if(r.length===0)throw Error(`setAtPath: jsonPath must be non-empty`);let i=e;for(let e=0;e<r.length-1;e++){let t=r[e],n=i[t];if(n===void 0){let e={};i[t]=e,i=e}else if(O(n))i=n;else throw Error(`setAtPath: cannot descend into non-object at '${r.slice(0,e+1).join(`.`)}'`)}i[r[r.length-1]]=n}function We(e,t){let n=Ve(t);if(n.length===0)throw Error(`deleteAtPath: jsonPath must be non-empty`);let r=e;for(let e=0;e<n.length-1;e++){if(!O(r))return;r=r[n[e]]}O(r)&&delete r[n[n.length-1]]}function Ge(e,t){let n=new Set(t),r=Object.keys(e),i=new Map;i.set(``,[]);let a=``;for(let e of r)n.has(e)?(a=e,i.set(a,[])):i.get(a).push(e);let o={};for(let t of i.get(``))o[t]=e[t];for(let n of t)if(n in e){o[n]=e[n];for(let t of i.get(n)??[])o[t]=e[t]}return o}function Ke(e){let t=e.split(`
|
|
10
|
+
`);return t.length>0&&t[t.length-1]===``&&t.pop(),t}function qe(e){return e.join(`
|
|
11
11
|
`)+`
|
|
12
|
-
`}function Ye(e){return e.replace(/(^|\s)#.*$/,`$1`).trim()}function Xe(e,t){let n=Ye(e);return n!==``&&n===t.trim()}function Ze(e,t){for(let n of e)if(Xe(n,t))return!0;return!1}function Qe(e,t){return e===`sdk:`?t?`workspace:*`:`catalog:`:e}var $e=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function et(e,t){if(M(e))for(let n of $e){let r=e[n];if(M(r))for(let e of Object.keys(r))r[e]===`sdk:`&&(r[e]=t?`workspace:*`:`catalog:`)}}var k;function tt(e){if(!k)throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);return k}function A(e){let t=tt(e);if(t.kind!==`json`)throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);return t}function j(e){let t=tt(e);if(t.kind!==`yaml`)throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);return t}function nt(e){let t=tt(e);if(t.kind!==`lines`)throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);return t}function rt(e,t){let n=e.ctx??Ce();if(!n)throw Error(`${t}() needs a RunContext but none is active. Pass { ctx } via the with-managed-* helper or run inside engine.run(...).`);return n}function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function it(e,t,n={}){if(k)throw Error(`Nested managed(...) body — engine bug.`);k={kind:`json`,obj:e,ctx:n.ctx,triggerContext:n.triggerContext};try{return t(n.ctx??n.triggerContext?.ctx),e}finally{k=void 0}}function at(e,t,n={}){if(k)throw Error(`Nested managed(...) body — engine bug.`);k={kind:`yaml`,doc:e,ctx:n.ctx,triggerContext:n.triggerContext,getLatestVersion:n.getLatestVersion,getDerivedDependencyPin:n.getDerivedDependencyPin};try{return t(n.ctx??n.triggerContext?.ctx),e}finally{k=void 0}}function ot(e,t,n={}){if(k)throw Error(`Nested managed(...) body — engine bug.`);k={kind:`lines`,lines:e,ctx:n.ctx,triggerContext:n.triggerContext};try{return t(n.ctx??n.triggerContext?.ctx),e}finally{k=void 0}}De((e,t)=>{if(!k)return!1;let n=k.triggerContext;if(!n)throw Error("when() inside a managed(...) body requires a triggerContext. The runner supplies it via the `triggerContext` opt to with-managed-*; ensure your test/test helper passes one.");return e(n)&&t(),!0});function N(e,t){We(A(`ensureField`).obj,e,t)}function P(e,t){let n=A(`removeField`).obj;Ue(n,e)&&(!t||t(He(n,e)))&&Ge(n,e)}function st(e,t){let n=A(`requireField`).obj;if(!Ue(n,e))throw Error(t??`requireField: missing field '${e}'`)}function ct(e,t){if(Ue(A(`forbidField`).obj,e))throw Error(t)}function lt(e,t){let n=A(`ensureFieldEntries`).obj,r=Ue(n,e)?He(n,e):void 0,i=M(r)?r:{};for(let[e,n]of Object.entries(t))i[e]=n;M(r)||We(n,e,i)}function F(e,t){N(`scripts.${e}`,t)}function I(e){P(`scripts.${e}`)}var ut=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function dt(e,t,n,r){let i=A(e),a=i.obj,o=n===`sdk:`?Qe(n,rt(i,e).isSdkInternal):n;for(let e of ut){if(e===r)continue;let n=a[e];M(n)&&t in n&&delete n[t]}let s=a[r],c=M(s)?s:{};c[t]=o,M(s)||(a[r]=c)}function L(e,t){dt(`ensureDep`,e,t,`dependencies`)}function R(e,t){dt(`ensureDevDep`,e,t,`devDependencies`)}function ft(e,t){dt(`ensurePeerDep`,e,t,`peerDependencies`)}function z(e){let t=A(`removeDep`).obj;for(let n of ut){let r=t[n];M(r)&&e in r&&delete r[e]}}function B(e){for(let[t,n]of Object.entries(e))R(t,n)}function V(e){for(let[t,n]of Object.entries(e))ft(t,n)}function pt(e,t,n){let r=rt(A(e),e);for(let i of r.modules)i.scope===t&&dt(e,i.name,`workspace:*`,n)}function mt(e){pt(`ensureWorkspaceScopeDeps`,e,`dependencies`)}function H(e){pt(`ensureWorkspaceScopeDevDeps`,e,`devDependencies`)}function ht(e){let t=A(`pruneKeysMatching`).obj;for(let n of Object.keys(t))e(n,t[n])&&delete t[n]}function gt(e,t){let n=Ke(e,t);for(let t of Object.keys(e))delete e[t];for(let t of Object.keys(n))e[t]=n[t]}function U(e){gt(A(`enforceFieldOrder`).obj,e)}function _t(e,t){let n=Object.keys(e).sort(),r={};for(let t of n)r[t]=e[t];for(let t of Object.keys(e))delete e[t];for(let i of n)e[i]=r[i],t&&M(e[i])&&_t(e[i],!0)}function W(e=``,t={}){let n=t.recursive??!1;if(e===``&&!n)return;let r=A(`enforceAlphabeticalOrder`).obj;if(e===``){_t(r,!0);return}let i=He(r,e);M(i)&&_t(i,n)}function vt(e,t){let n=A(`transformAt`).obj;We(n,e,t(He(n,e)))}function yt(){let e=j(`ensureWorkspaceModulePaths`),t=rt(e,`ensureWorkspaceModulePaths`).modules.filter(e=>e.path!==``).map(e=>e.path).sort(),n=e.doc.toJSON()?.packages;Array.isArray(n)&&n.length===t.length&&n.every((e,n)=>e===t[n])||e.doc.setIn([`packages`],t)}function bt(e,t){let n=e.doc.getIn([`catalog`,t]);return typeof n==`string`?n:void 0}function xt(e,t){let n=j(`ensureCatalogVersion`);bt(n,e)===void 0&&n.doc.setIn([`catalog`,e],t)}function St(e){let t=j(`ensureCatalogLatest`);if(!t.getLatestVersion)return;let n=t.getLatestVersion(e);n!==void 0&&bt(t,e)!==n&&t.doc.setIn([`catalog`,e],n)}function Ct(e,t){let n=j(`pinCatalogToDependencyOf`);if(!n.getDerivedDependencyPin)return;let r=n.getDerivedDependencyPin(e);r!==void 0&&bt(n,e)!==r&&n.doc.setIn([`catalog`,e],r)}function wt(e,t){let n=j(`ensureCatalogAtLeast`),r=bt(n,e),i=(0,Ne.minVersion)(t),a=r!==void 0&&(0,Ne.validRange)(r)!==null?(0,Ne.minVersion)(r):null;(r===void 0||i!==null&&a!==null&&!(0,Ne.gte)(a,i))&&n.doc.setIn([`catalog`,e],t)}function Tt(e){let t=j(`ensureCatalogAbsent`);t.doc.hasIn([`catalog`,e])&&t.doc.deleteIn([`catalog`,e])}function Et(e,t,{keepExisting:n=!1}={}){let r=j(`ensureWorkspaceMapEntries`);(0,s.isMap)(r.doc.get(e))||r.doc.delete(e);let i=Object.entries(t).filter(([t,i])=>n?!r.doc.hasIn([e,t]):r.doc.getIn([e,t])!==i);for(let[t,n]of i)r.doc.setIn([e,t],n)}function Dt(e,t){let n=j(`ensureWorkspaceListItems`),r=n.doc.toJSON()?.[e],i=new Set(Array.isArray(r)?r:[]),a=t.filter(e=>!i.has(e));if(a.length!==0){if(!(0,s.isSeq)(n.doc.get(e)))n.doc.set(e,a);else for(let t of a)n.doc.addIn([e],t)}}function Ot(e){let t=nt(`ensureGitignoreEntries`);for(let n of e)Ze(t.lines,n)||t.lines.push(n)}function kt(e){return(0,s.parseDocument)(e)}function At(e){return e.toString()}var jt=`.structure`;function Mt(e){if(!e.exists(`.structure`))return{version:0};try{let t=JSON.parse(e.read(jt));return{version:typeof t?.version==`number`?t.version:0}}catch{return{version:0}}}function Nt(e,t=0){if(e<t)throw new Pt(e,t)}var Pt=class extends Error{version;floor;constructor(e,t){super(`Block .structure version is ${e}, below floor ${t}. Bootstrap via the legacy-migration skill, then re-run.`),this.version=e,this.floor=t,this.name=`StructureVersionFloorError`}};function Ft(e,t){e.write(jt,JSON.stringify(t))}var It=class extends Error{failing;constructor(e){super(`Post-run recheck: rule set not idempotent. Failing item: ${e.primitive} '${e.path}' (scope=${e.scope}, action=${e.action}). Engine bug.`),this.failing=e,this.name=`RecheckError`}};function Lt(e,t,n,r){switch(e.kind){case`text`:return e.value;case`file`:if(!n)throw Error(`file('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);return n.staticRead(e.path);case`tpl`:if(!n)throw Error(`tpl('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);return ue(n.textRead(e.path),typeof e.vars==`function`?e.vars(r):e.vars);case`generate`:{let n=e.fn(r);if(t.endsWith(`.json`))return et(n,r.isSdkInternal),Be(n,{collapse:!t.endsWith(`package.json`)});if(t.endsWith(`.yaml`)||t.endsWith(`.yml`))return(0,s.stringify)(n);if(typeof n!=`string`)throw Error(`generate() for '${t}' must return a string for non-JSON/YAML files; got ${typeof n}`);return n}case`binary`:throw Error(`binary('${e.path}') cannot be resolved to a string; it is only valid inside seed()/scaffold(), which copy it verbatim via fs.writeBinary.`)}}function Rt(e,t,n,r,i){if(n.kind===`binary`){if(!r)throw Error(`binary('${n.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);e.writeBinary(t,r.staticReadBinary(n.path))}else e.write(t,Lt(n,t,r,i))}function zt(e,t,n,r,i,a){let o=e.split(`/`).pop()??e;if(e.endsWith(`.json`)){let i=Pe(t);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`managed: parsed value at '${e}' is not a JSON object`);return it(i,n,{triggerContext:r}),Be(i,{collapse:o!==`package.json`})}if(e.endsWith(`.yaml`)||e.endsWith(`.yml`)){let e=kt(t);return at(e,n,{triggerContext:r,getLatestVersion:i,getDerivedDependencyPin:a}),At(e)}if(o===`.gitignore`||o.endsWith(`.gitignore`)){let e=qe(t);return ot(e,n,{triggerContext:r}),Je(e)}throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`)}function Bt(e){let t=e.list(``),n=new Set;for(let e of t){n.add(e);let t=e.split(`/`);for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`))}return n}function Vt(e,t){let n=t===``?t:t.endsWith(`/`)?t.slice(0,-1):t;return e.has(n)}function Ht(e,t,n){return{ctx:t,version:t.version,pathExists:t=>Vt(e,t),pathMissing:t=>!Vt(e,t),filesMatch:t=>{let r=n?`${n}/${t}`:t;for(let t of e)if(ye(r,t))return!0;return!1}}}function Ut(e,t){for(let n of e.triggers)if(!n(t))return!1;return!0}function Wt(e,t){return t?`init`:e.updateDepsOnly?`updateDeps`:`default`}function Gt(e,t){return e.filter(e=>e.modes.includes(t))}function Kt(e,t,n,r,i,a){let o=e.leaf;if(o.kind===`fixed`){let i=Lt(o.content,e.resolvedPath,r,a);return t.exists(e.resolvedPath)?t.read(e.resolvedPath)===i?void 0:(n||t.write(e.resolvedPath,i),{scope:e.scope,path:e.resolvedPath,primitive:`fixed`,action:`update`}):(n||t.write(e.resolvedPath,i),{scope:e.scope,path:e.resolvedPath,primitive:`fixed`,action:`create`})}if(o.kind===`scaffold`)return t.exists(e.resolvedPath)?void 0:(n||Rt(t,e.resolvedPath,o.initial,r,a),{scope:e.scope,path:e.resolvedPath,primitive:`scaffold`,action:`create`});if(o.kind===`seed`)return!i||t.exists(e.resolvedPath)?void 0:(n||Rt(t,e.resolvedPath,o.initial,r,a),{scope:e.scope,path:e.resolvedPath,primitive:`seed`,action:`create`});if(o.kind===`remove`)return t.exists(e.resolvedPath)?(n||t.delete(e.resolvedPath),{scope:e.scope,path:e.resolvedPath,primitive:`remove`,action:`delete`}):void 0;if(o.kind===`rename`){if(!t.exists(e.resolvedPath))return;let r=e.resolvedTo;return t.exists(r)?void 0:(n||t.move(e.resolvedPath,r),{scope:e.scope,path:e.resolvedPath,primitive:`rename`,action:`rename`})}}function qt(e,t,n,r,i,a,o,s){if(e.leaf.kind!==`managed`)return;let c=e.leaf,l=e.resolvedPath,u=t.exists(l),d,f=!1;u?d=t.read(l):(d=Lt(c.initial,l,i,s),f=!0);let p=zt(l,d,c.body,r,a,o);if(f)return n||t.write(l,p),{scope:e.scope,path:l,primitive:`managed`,action:`create`};if(p!==d)return n||t.write(l,p),{scope:e.scope,path:l,primitive:`managed`,action:`update`}}function Jt(e,t,n,r,i,a,o,s){let c=Gt(e,Wt(n,a)),l=[],u=Bt(t);for(let e of c){if(e.leaf.kind===`managed`||!Ut(e,Ht(u,n,e.modulePath)))continue;let o=Kt(e,t,r,i,a,n);o&&l.push(o)}let d=Bt(t);for(let e of c){if(e.leaf.kind!==`managed`)continue;let a=Ht(d,n,e.modulePath);if(!Ut(e,a))continue;let c=qt(e,t,r,a,i,o,s,n);c&&l.push(c)}return l}function Yt(e,t,n,r={}){return Se(n,()=>{let i=me(e,n),a=!!r.initMode,o=Jt(i,t,n,n.dryRun,r.templates,a,r.registryLookup,r.derivedPinLookup);if(!n.dryRun&&!n.updateDepsOnly&&!a){Ft(t,{version:3});let i={...r.rediscover?r.rediscover(t):n,dryRun:!0},a=Jt(me(e,i),t,i,!0,r.templates,!1,r.registryLookup,r.derivedPinLookup).filter(e=>e.path!==jt);if(a.length>0)throw new It(a[0])}return a&&!n.dryRun&&Ft(t,{version:3}),{changes:o}})}var Xt=[`root`,`block`,`model`,`ui`,`workflow`,`test`,`software`,`kind`],Zt=class extends Error{path;constructor(e,t){super(e),this.path=t,this.name=`DiscoveryError`}};function Qt(e){let t=new Set;for(let n of[e.dependencies,e.devDependencies,e.peerDependencies,e.optionalDependencies])if(n)for(let e of Object.keys(n))t.add(e);return t}function $t(e){return e===``||e===`.`}function en(e){let t=e.pkg[`block-scope`];if(typeof t==`string`){if(!Xt.includes(t))throw new Zt(`package.json "block-scope" must be one of ${Xt.join(`, `)}, got '${t}'`,e.path);return t}if($t(e.path))return`root`;if(e.pkg.block!==void 0)return`block`;let n=Qt(e.pkg);if(n.has(`@platforma-sdk/block-kind`))return`kind`;if(e.pkg[`block-software`]!==void 0)return`software`;if(n.has(`@platforma-sdk/package-builder`)){for(let e of n)if(/^@platforma-open\/.*runenv/.test(e))return`software`}if(n.has(`@platforma-sdk/workflow-tengo`))return`workflow`;if((n.has(`@platforma-sdk/ui-vue`)||n.has(`vue`))&&!e.pkg.main)return`ui`;if(n.has(`@platforma-sdk/model`)&&e.pkg.main)return`model`;if(n.has(`@platforma-sdk/test`))return`test`}function tn(e){let t=[];for(let n of e){let e=en(n);if(!e)throw new Zt(`Unclassified workspace package at '${n.path}'. Add a top-level "block-scope" string to its package.json.`,n.path);t.push({scope:e,name:n.pkg.name??n.path,path:$t(n.path)?``:n.path})}return t}function G(e,t){return e.modules.filter(e=>e.scope===t)}function nn(e,t){let n=G(e,t);if(n.length===0)throw Error(`findModule: expected one '${t}' module, found none`);if(n.length>1)throw Error(`findModule: expected exactly one '${t}' module, found ${n.length}`);return n[0]}function rn(e,t){return{[nn(e,t).name]:`workspace:*`}}function K(e,t){let n={};for(let r of G(e,t))n[r.name]=`workspace:*`;return n}function an(e){let t=e.facadeName,n=[{scope:`root`,name:t,path:``},{scope:`block`,name:`${t}.block`,path:`block`},{scope:`model`,name:`${t}.model`,path:`model`},{scope:`kind`,name:`${t}.kind`,path:`kind`},{scope:`ui`,name:`${t}.ui`,path:`ui`},{scope:`workflow`,name:`${t}.workflow`,path:`workflow`},{scope:`test`,name:`${t}.test`,path:`test`}];return e.softwarePlatform&&n.push({scope:`software`,name:`${t}.software`,path:`software`}),n}function on(e){return{isSdkInternal:e.isSdkInternal??!1,updateDepsOnly:e.updateDepsOnly??!1,modules:e.modules,blockVars:e.blockVars,version:e.version??0,dryRun:e.dryRun??!1}}var q=class extends Error{constructor(e){super(e),this.name=`StructureCliError`}};function sn(e,t){return e===``?t:`${e}/${t}`}function cn(e,t){try{return JSON.parse(e.read(t))}catch{return}}function ln(e){if(e.includes(`*`))throw new q(`pnpm-workspace.yaml 'packages:' entry '${e}' contains a glob. The structurer requires literal package paths — replace the glob with one entry per package directory.`);let t=e.replace(/^\.\//,``).replace(/\/$/,``);return t===`.`?``:t}function un(e){let t;try{t=e.read(`pnpm-workspace.yaml`)}catch{throw new q(`No pnpm-workspace.yaml found. This directory is empty or unrecognisable as a block — run 'block-tools structure init' instead, or pass --sdk-internal for an in-monorepo block.`)}let n=(0,s.parse)(t)??{},r=Array.isArray(n.packages)?n.packages:[],i=new Set([``]);for(let t of r){let n=ln(t);(n===``||e.exists(n))&&i.add(n)}let a=[];for(let t of i){let n=cn(e,sn(t,`package.json`));n&&a.push({path:t,pkg:n})}return a}function dn(e){let t=[],n=new Set([`node_modules`,`.turbo`,`dist`,`.git`,`block-pack`]);function r(i,a){let o=e.listDir(i);for(let s of o){if(!s.isDirectory||n.has(s.name))continue;let o=sn(i,s.name),c=cn(e,sn(o,`package.json`));c&&t.push({path:o,pkg:c}),a<2&&r(o,a+1)}}return r(``,1),t}function fn(e){let t=e.indexOf(`/`);if(!e.startsWith(`@`)||t<0)throw new q(`Cannot parse block name '${e}': expected '@npm-org/org-scope.short-name'.`);let n=e.slice(0,t),r=e.slice(t+1),i=r.indexOf(`.`);if(i<0)throw new q(`Cannot parse block name '${e}': base name '${r}' has no '.' separating org-scope from short-name.`);return{facadeName:e,baseName:r,npmOrg:n,orgScope:r.slice(0,i),shortName:r.slice(i+1)}}function pn(e){let{fs:t,isSdkInternal:n}=e,r=n?dn(t):un(t);if(r.length===0)throw new q(`No workspace packages found. Run 'block-tools structure init' to scaffold a block.`);let i=tn(r),a=Mt(t);Nt(a.version,0);let o=i.find(e=>e.scope===`block`)??i.find(e=>e.scope===`root`);if(!o)throw new q(`Could not find a 'block' (or root-as-block) package to derive BlockVars from.`);let s=o.name.replace(/\.block$/,``),c=fn(s);return i.some(e=>e.scope===`kind`)||i.push({scope:`kind`,name:`${s}.kind`,path:`kind`}),on({isSdkInternal:n,updateDepsOnly:e.updateDepsOnly??!1,modules:i,blockVars:c,version:a.version,dryRun:e.dryRun??!1})}var J=[`name`,`version`,`private`,`description`,`keywords`,`files`,`type`,`main`,`module`,`types`,`exports`,`scripts`,`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`,`devEngines`,`engines`,`packageManager`,`block`,`block-software`],Y=`1.0.0`;function X(){vt(`version`,e=>typeof e==`string`&&e.length>0?e:Y)}var mn=`24.22.1`,hn={name:`node`,version:mn,onFail:`download`},gn=`pnpm@12.16.1+sha512.091d1dee7927575661b25dab3c2ae31cafc1c54d6b71ed6a6600cf0c1cb10434a447eae14015f1b23e2e6bedeed79df94a932e2164d2832280dce3fb32f656d1`,_n=`~2.11.10`,vn=[`@milaboratories/*`,`@platforma-sdk/*`,`@platforma-open/*`],yn={"@milaboratories/pframes-rs-node":!0},bn={"@milaboratories/tengo-tester":!1,"cpu-features":!1,esbuild:!1,protobufjs:!1,ssh2:!1},xn={"build:dev-local":`env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=local turbo run build`,"build:dev-remote":`env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build`,"build:dev-no-software":`env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=none turbo run build`,"build:dev-binary-existing":`env PL_BUILD_CHANNEL=dev PL_BUILD_USE_PUBLISHED=true turbo run build`,"build:release":`env PL_BUILD_CHANNEL=release PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build`},Sn={test:`env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --concurrency 1`,"test:dry-run":`env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --dry-run=json`};function Cn(){return{version:Y,private:!0,scripts:{fmt:`turbo run fmt`,check:`turbo run check`,...xn,...Sn,"mark-stable":`turbo run mark-stable`,"do-pack":`turbo run do-pack`,watch:`turbo watch build`,changeset:`changeset`,"version-packages":`changeset version`,"update-sdk":`block-tools structure refresh --update-deps-only`,"upgrade-sdk":`block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt`},peerDependencies:{oxlint:`*`,oxfmt:`*`},devDependencies:{"@changesets/cli":`catalog:`,"@milaboratories/ts-builder":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,shx:`catalog:`,turbo:`catalog:`}}}function wn(){N(`packageManager`,gn),N(`devEngines.runtime`,hn),P(`pnpm`,e=>e===null||typeof e==`object`&&Object.values(e).every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===0)),ct(`pnpm`,`pnpm 11+ ignores the "pnpm" field in package.json. Move its settings to pnpm-workspace.yaml: overrides as is, onlyBuiltDependencies as allowBuilds true, neverBuiltDependencies as allowBuilds false.`),P(`name`),F(`fmt`,`turbo run fmt`),F(`check`,`turbo run check`);for(let[e,t]of Object.entries(xn))F(e,t);for(let[e,t]of Object.entries(Sn))F(e,t);I(`build`),I(`build:dev`),F(`mark-stable`,`turbo run mark-stable`),F(`do-pack`,`turbo run do-pack`),F(`watch`,`turbo watch build`),F(`changeset`,`changeset`),F(`version-packages`,`changeset version`),F(`update-sdk`,`block-tools structure refresh --update-deps-only`),I(`update`),F(`upgrade-sdk`,`block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt`),B({"@changesets/cli":`catalog:`,"@milaboratories/ts-builder":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,shx:`catalog:`,turbo:`catalog:`}),V({oxlint:`*`,oxfmt:`*`}),ht((e,t)=>{if(!/^(\/\/|--)/.test(e)||typeof t!=`object`||!t)return!1;let n=t;return n.pnpm!==void 0||n.overrides!==void 0}),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}var Tn=`https://turbo.build/schema.json`,En=[`tsconfig.json`],Dn={fmt:{cache:!1},check:{dependsOn:[`^build`],outputs:[]},build:{dependsOn:[`^build`,`check`],inputs:[`$TURBO_DEFAULT$`],env:[`PL_DOCKER_REGISTRY_PUSH_TO`,`PL_BUILD_CHANNEL`,`PL_BUILD_VARIANT`,`PL_BUILD_LOCATION`,`PL_BUILD_USE_PUBLISHED`,`PL_DEV_DOCKER_PUSH_URL`,`PL_DEV_DOCKER_PULL_URL`,`PL_DEV_BINARY_UPLOAD_URL`,`PL_RELEASE_DOCKER_PUSH_URL`,`PL_RELEASE_DOCKER_PULL_URL`,`PL_RELEASE_BINARY_UPLOAD_URL`,`PL_REGISTRY_PLATFORMA_OPEN_UPLOAD_URL`],passThroughEnv:[`AWS_*`,`PL_AWS_*`],outputs:[`./dist/**`,`./block-pack/**`,`./pkg-*.tgz`]},"do-pack":{dependsOn:[`build`],outputs:[`package.tgz`]},test:{dependsOn:[`build`,`check`],passThroughEnv:[`PL_ADDRESS`,`PL_TEST_PASSWORD`,`PL_TEST_USER`,`PL_TEST_PROXY`,`DEBUG`]},"mark-stable":{passThroughEnv:[`PL_REGISTRY`,`AWS_*`],cache:!1}};function On(){return{$schema:Tn,globalDependencies:En,tasks:{...Dn}}}function kn(){N(`$schema`,Tn),N(`globalDependencies`,En),lt(`tasks`,Dn),P(`tasks.build:dev`),U([`$schema`,`globalDependencies`,`tasks`])}var An=2,jn=500,Mn=3e4;function Nn(e){if(!e)return null;let t=Number(e);if(Number.isFinite(t)&&t>0)return t*1e3;let n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,n-Date.now())}async function Pn(e){for(let t=1;;t++){let n;try{n=await fetch(e,{signal:AbortSignal.timeout(Mn)})}catch(e){if(t>An)throw e;let n=jn*2**(t-1)*(.8+.4*Math.random());await(0,c.setTimeout)(n);continue}if(n.ok)return n;if(!(n.status===429||n.status>=500)||t>An)throw Error(`registry returned HTTP ${n.status}`);let r=Nn(n.headers.get(`retry-after`));if(r!=null){await(0,c.setTimeout)(r);continue}let i=jn*2**(t-1)*(.8+.4*Math.random());await(0,c.setTimeout)(i)}}function Fn(){return{async getLatestVersion(e){let t=(await(await Pn(`https://registry.npmjs.org/-/package/${e}/dist-tags`)).json()).latest;if(!t)throw Error(`no 'latest' dist-tag in registry response`);return t},async getDeclaredDependency(e,t,n){let r=await(await Pn(`https://registry.npmjs.org/${e}/${t}`)).json();return r.dependencies?.[n]??r.peerDependencies?.[n]}}}async function In(e,t){let n=await Promise.all(t.map(async t=>[t,await e.getLatestVersion(t)]));return new Map(n)}function Ln(e){return t=>e.get(t)}var Rn=[/^@platforma-sdk\//,/^@milaboratories\//];function zn(e){return Rn.some(t=>t.test(e))}async function Bn(e,t=Fn()){return e.length===0?()=>void 0:Ln(await In(t,e))}function Vn(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e)}async function Hn(e,t=Fn()){if(e.length===0)return()=>void 0;let n=await Promise.all(e.map(async e=>{let n=await t.getDeclaredDependency(e.of,e.ofVersion??`latest`,e.entry);if(n===void 0)throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion?`@${e.ofVersion}`:` (latest)`} declares no dependency '${e.entry}'. A derived pin requires the source to declare the dep as an exact version.`);if(!Vn(n))throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion?`@${e.ofVersion}`:` (latest)`} declares '${e.entry}: ${n}', which is not an exact version. A derived pin requires an exact ('x.y.z') source dependency so the catalog can pin to it precisely.`);return[e.entry,n]})),r=new Map(n);return e=>r.get(e)}var Un=[`vite`,`tsup`,`vue-tsc`,`@vitejs/plugin-vue`,`vite-plugin-dts`,`@platforma-sdk/eslint-config`];function Wn(){for(let e of Un)z(e)}var Z=[`@platforma-sdk/model`,`@platforma-sdk/ui-vue`,`@platforma-sdk/workflow-tengo`,`@platforma-sdk/test`,`@platforma-sdk/block-kind`,`@platforma-sdk/block-tools`,`@platforma-sdk/block-kind`,`@platforma-sdk/tengo-builder`,`@platforma-sdk/package-builder`,`@milaboratories/ts-builder`,`@milaboratories/ts-configs`],Gn=`0.0.0-init-must-fetch`;for(let e of Z)if(!zn(e))throw Error(`SDK_CATALOG_PACKAGES entry '${e}' matches no catalog bump pattern; its placeholder would never be resolved to npm latest on init. Add it to CATALOG_BUMP_PATTERNS or move it to the infra floor.`);var Kn={turbo:_n,shx:`~0.4.0`,"@changesets/cli":`~2.29.8`,vitest:`~4.0.18`,typescript:`~5.9.3`},qn=[{entry:`vue`,of:`@platforma-sdk/ui-vue`},{entry:`@milaboratories/helpers`,of:`@platforma-sdk/model`}],Jn=`@platforma-open/milaboratories.runenv-python-3`,Yn=`1.8.2`;function Xn(e){let t=e.modules.filter(e=>e.path!==``).map(e=>e.path).sort(),n={};for(let e of Z)n[e]=Gn;return Object.assign(n,Kn),e.modules.some(e=>e.scope===`software`)&&(n[Jn]=Yn),{packages:t,catalog:n}}function Zn(){yt(),Dt(`minimumReleaseAgeExclude`,vn),Et(`allowBuilds`,bn,{keepExisting:!0}),Et(`allowBuilds`,yn),wt(`turbo`,_n);for(let e of Un)Tt(e)}var Qn=[`.test_auth.json`,`node_modules/`,`dist/`,`block-pack/`,`dev/`,`work/`,`log/`,`.turbo`,`vite.config.*.timestamp-*`,`software/**/*.tgz`,`.DS_Store`,`.vscode/sftp.json`,`test-dry-run.json`];function $n(){Ot(Qn)}var er=`---
|
|
12
|
+
`}function Je(e){return e.replace(/(^|\s)#.*$/,`$1`).trim()}function Ye(e,t){let n=Je(e);return n!==``&&n===t.trim()}function Xe(e,t){for(let n of e)if(Ye(n,t))return!0;return!1}function Ze(e,t){return e===`sdk:`?t?`workspace:*`:`catalog:`:e}var Qe=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function $e(e,t){if(N(e))for(let n of Qe){let r=e[n];if(N(r))for(let e of Object.keys(r))r[e]===`sdk:`&&(r[e]=t?`workspace:*`:`catalog:`)}}var A;function et(e){if(!A)throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);return A}function j(e){let t=et(e);if(t.kind!==`json`)throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);return t}function M(e){let t=et(e);if(t.kind!==`yaml`)throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);return t}function tt(e){let t=et(e);if(t.kind!==`lines`)throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);return t}function nt(e,t){let n=e.ctx??Ce();if(!n)throw Error(`${t}() needs a RunContext but none is active. Pass { ctx } via the with-managed-* helper or run inside engine.run(...).`);return n}function N(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rt(e,t,n={}){if(A)throw Error(`Nested managed(...) body — engine bug.`);A={kind:`json`,obj:e,ctx:n.ctx,triggerContext:n.triggerContext};try{return t(n.ctx??n.triggerContext?.ctx),e}finally{A=void 0}}function it(e,t,n={}){if(A)throw Error(`Nested managed(...) body — engine bug.`);A={kind:`yaml`,doc:e,ctx:n.ctx,triggerContext:n.triggerContext,getLatestVersion:n.getLatestVersion,getDerivedDependencyPin:n.getDerivedDependencyPin};try{return t(n.ctx??n.triggerContext?.ctx),e}finally{A=void 0}}function at(e,t,n={}){if(A)throw Error(`Nested managed(...) body — engine bug.`);A={kind:`lines`,lines:e,ctx:n.ctx,triggerContext:n.triggerContext};try{return t(n.ctx??n.triggerContext?.ctx),e}finally{A=void 0}}De((e,t)=>{if(!A)return!1;let n=A.triggerContext;if(!n)throw Error("when() inside a managed(...) body requires a triggerContext. The runner supplies it via the `triggerContext` opt to with-managed-*; ensure your test/test helper passes one.");return e(n)&&t(),!0});function P(e,t){Ue(j(`ensureField`).obj,e,t)}function F(e,t){let n=j(`removeField`).obj;k(n,e)&&(!t||t(He(n,e)))&&We(n,e)}function ot(e,t){let n=j(`requireField`).obj;if(!k(n,e))throw Error(t??`requireField: missing field '${e}'`)}function st(e,t){if(k(j(`forbidField`).obj,e))throw Error(t)}function ct(e,t){let n=j(`ensureFieldEntries`).obj,r=k(n,e)?He(n,e):void 0,i=N(r)?r:{};for(let[e,n]of Object.entries(t))i[e]=n;N(r)||Ue(n,e,i)}function I(e,t){P(`scripts.${e}`,t)}function L(e){F(`scripts.${e}`)}var lt=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function ut(e,t,n,r){let i=j(e),a=i.obj,o=n===`sdk:`?Ze(n,nt(i,e).isSdkInternal):n;for(let e of lt){if(e===r)continue;let n=a[e];N(n)&&t in n&&delete n[t]}let s=a[r],c=N(s)?s:{};c[t]=o,N(s)||(a[r]=c)}function R(e,t){ut(`ensureDep`,e,t,`dependencies`)}function z(e,t){ut(`ensureDevDep`,e,t,`devDependencies`)}function dt(e,t){ut(`ensurePeerDep`,e,t,`peerDependencies`)}function B(e){let t=j(`removeDep`).obj;for(let n of lt){let r=t[n];N(r)&&e in r&&delete r[e]}}function V(e){for(let[t,n]of Object.entries(e))z(t,n)}function H(e){for(let[t,n]of Object.entries(e))dt(t,n)}function ft(e,t,n){let r=nt(j(e),e);for(let i of r.modules)i.scope===t&&ut(e,i.name,`workspace:*`,n)}function pt(e){ft(`ensureWorkspaceScopeDeps`,e,`dependencies`)}function mt(e){ft(`ensureWorkspaceScopeDevDeps`,e,`devDependencies`)}function ht(e){let t=j(`pruneKeysMatching`).obj;for(let n of Object.keys(t))e(n,t[n])&&delete t[n]}function gt(e,t){let n=Ge(e,t);for(let t of Object.keys(e))delete e[t];for(let t of Object.keys(n))e[t]=n[t]}function U(e){gt(j(`enforceFieldOrder`).obj,e)}function _t(e,t){let n=Object.keys(e).sort(),r={};for(let t of n)r[t]=e[t];for(let t of Object.keys(e))delete e[t];for(let i of n)e[i]=r[i],t&&N(e[i])&&_t(e[i],!0)}function W(e=``,t={}){let n=t.recursive??!1;if(e===``&&!n)return;let r=j(`enforceAlphabeticalOrder`).obj;if(e===``){_t(r,!0);return}let i=He(r,e);N(i)&&_t(i,n)}function vt(e,t){let n=j(`transformAt`).obj;Ue(n,e,t(He(n,e)))}function yt(){let e=M(`ensureWorkspaceModulePaths`),t=nt(e,`ensureWorkspaceModulePaths`).modules.filter(e=>e.path!==``).map(e=>e.path).sort(),n=e.doc.toJSON()?.packages;Array.isArray(n)&&n.length===t.length&&n.every((e,n)=>e===t[n])||e.doc.setIn([`packages`],t)}function bt(e,t){let n=e.doc.getIn([`catalog`,t]);return typeof n==`string`?n:void 0}function xt(e,t){let n=M(`ensureCatalogVersion`);bt(n,e)===void 0&&n.doc.setIn([`catalog`,e],t)}function St(e){let t=M(`ensureCatalogLatest`);if(!t.getLatestVersion)return;let n=t.getLatestVersion(e);n!==void 0&&bt(t,e)!==n&&t.doc.setIn([`catalog`,e],n)}function Ct(e,t){let n=M(`pinCatalogToDependencyOf`);if(!n.getDerivedDependencyPin)return;let r=n.getDerivedDependencyPin(e);r!==void 0&&bt(n,e)!==r&&n.doc.setIn([`catalog`,e],r)}function wt(e,t){let n=M(`ensureCatalogAtLeast`),r=bt(n,e),i=(0,Ne.minVersion)(t),a=r!==void 0&&(0,Ne.validRange)(r)!==null?(0,Ne.minVersion)(r):null;(r===void 0||i!==null&&a!==null&&!(0,Ne.gte)(a,i))&&n.doc.setIn([`catalog`,e],t)}function Tt(e){let t=M(`ensureCatalogAbsent`);t.doc.hasIn([`catalog`,e])&&t.doc.deleteIn([`catalog`,e])}function Et(e,t,{keepExisting:n=!1}={}){let r=M(`ensureWorkspaceMapEntries`);(0,s.isMap)(r.doc.get(e))||r.doc.delete(e);let i=Object.entries(t).filter(([t,i])=>n?!r.doc.hasIn([e,t]):r.doc.getIn([e,t])!==i);for(let[t,n]of i)r.doc.setIn([e,t],n)}function Dt(e,t){let n=M(`ensureWorkspaceListItems`),r=n.doc.toJSON()?.[e],i=new Set(Array.isArray(r)?r:[]),a=t.filter(e=>!i.has(e));if(a.length!==0){if(!(0,s.isSeq)(n.doc.get(e)))n.doc.set(e,a);else for(let t of a)n.doc.addIn([e],t)}}function Ot(e){let t=tt(`ensureGitignoreEntries`);for(let n of e)Xe(t.lines,n)||t.lines.push(n)}function kt(e){return(0,s.parseDocument)(e)}function At(e){return e.toString()}var jt=`.structure`;function Mt(e){if(!e.exists(`.structure`))return{version:0};try{let t=JSON.parse(e.read(jt));return{version:typeof t?.version==`number`?t.version:0}}catch{return{version:0}}}function Nt(e,t=0){if(e<t)throw new Pt(e,t)}var Pt=class extends Error{version;floor;constructor(e,t){super(`Block .structure version is ${e}, below floor ${t}. Bootstrap via the legacy-migration skill, then re-run.`),this.version=e,this.floor=t,this.name=`StructureVersionFloorError`}};function Ft(e,t){e.write(jt,JSON.stringify(t))}var It=class extends Error{failing;constructor(e){super(`Post-run recheck: rule set not idempotent. Failing item: ${e.primitive} '${e.path}' (scope=${e.scope}, action=${e.action}). Engine bug.`),this.failing=e,this.name=`RecheckError`}};function Lt(e,t,n,r){switch(e.kind){case`text`:return e.value;case`file`:if(!n)throw Error(`file('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);return n.staticRead(e.path);case`tpl`:if(!n)throw Error(`tpl('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);return ue(n.textRead(e.path),typeof e.vars==`function`?e.vars(r):e.vars);case`generate`:{let n=e.fn(r);if(t.endsWith(`.json`))return $e(n,r.isSdkInternal),Be(n,{collapse:!t.endsWith(`package.json`)});if(t.endsWith(`.yaml`)||t.endsWith(`.yml`))return(0,s.stringify)(n);if(typeof n!=`string`)throw Error(`generate() for '${t}' must return a string for non-JSON/YAML files; got ${typeof n}`);return n}case`binary`:throw Error(`binary('${e.path}') cannot be resolved to a string; it is only valid inside seed()/scaffold(), which copy it verbatim via fs.writeBinary.`)}}function Rt(e,t,n,r,i){if(n.kind===`binary`){if(!r)throw Error(`binary('${n.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);e.writeBinary(t,r.staticReadBinary(n.path))}else e.write(t,Lt(n,t,r,i))}function zt(e,t,n,r,i,a){let o=e.split(`/`).pop()??e;if(e.endsWith(`.json`)){let i=Pe(t);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`managed: parsed value at '${e}' is not a JSON object`);return rt(i,n,{triggerContext:r}),Be(i,{collapse:o!==`package.json`})}if(e.endsWith(`.yaml`)||e.endsWith(`.yml`)){let e=kt(t);return it(e,n,{triggerContext:r,getLatestVersion:i,getDerivedDependencyPin:a}),At(e)}if(o===`.gitignore`||o.endsWith(`.gitignore`)){let e=Ke(t);return at(e,n,{triggerContext:r}),qe(e)}throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`)}function Bt(e){let t=e.list(``),n=new Set;for(let e of t){n.add(e);let t=e.split(`/`);for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`))}return n}function Vt(e,t){let n=t===``?t:t.endsWith(`/`)?t.slice(0,-1):t;return e.has(n)}function Ht(e,t,n){return{ctx:t,version:t.version,pathExists:t=>Vt(e,t),pathMissing:t=>!Vt(e,t),filesMatch:t=>{let r=n?`${n}/${t}`:t;for(let t of e)if(ye(r,t))return!0;return!1}}}function Ut(e,t){for(let n of e.triggers)if(!n(t))return!1;return!0}function Wt(e,t){return t?`init`:e.updateDepsOnly?`updateDeps`:`default`}function Gt(e,t){return e.filter(e=>e.modes.includes(t))}function Kt(e,t,n,r,i,a){let o=e.leaf;if(o.kind===`fixed`){let i=Lt(o.content,e.resolvedPath,r,a);return t.exists(e.resolvedPath)?t.read(e.resolvedPath)===i?void 0:(n||t.write(e.resolvedPath,i),{scope:e.scope,path:e.resolvedPath,primitive:`fixed`,action:`update`}):(n||t.write(e.resolvedPath,i),{scope:e.scope,path:e.resolvedPath,primitive:`fixed`,action:`create`})}if(o.kind===`scaffold`)return t.exists(e.resolvedPath)?void 0:(n||Rt(t,e.resolvedPath,o.initial,r,a),{scope:e.scope,path:e.resolvedPath,primitive:`scaffold`,action:`create`});if(o.kind===`seed`)return!i||t.exists(e.resolvedPath)?void 0:(n||Rt(t,e.resolvedPath,o.initial,r,a),{scope:e.scope,path:e.resolvedPath,primitive:`seed`,action:`create`});if(o.kind===`remove`)return t.exists(e.resolvedPath)?(n||t.delete(e.resolvedPath),{scope:e.scope,path:e.resolvedPath,primitive:`remove`,action:`delete`}):void 0;if(o.kind===`rename`){if(!t.exists(e.resolvedPath))return;let r=e.resolvedTo;return t.exists(r)?void 0:(n||t.move(e.resolvedPath,r),{scope:e.scope,path:e.resolvedPath,primitive:`rename`,action:`rename`})}}function qt(e,t,n,r,i,a,o,s){if(e.leaf.kind!==`managed`)return;let c=e.leaf,l=e.resolvedPath,u=t.exists(l),d,f=!1;u?d=t.read(l):(d=Lt(c.initial,l,i,s),f=!0);let p=zt(l,d,c.body,r,a,o);if(f)return n||t.write(l,p),{scope:e.scope,path:l,primitive:`managed`,action:`create`};if(p!==d)return n||t.write(l,p),{scope:e.scope,path:l,primitive:`managed`,action:`update`}}function Jt(e,t,n,r,i,a,o,s){let c=Gt(e,Wt(n,a)),l=[],u=Bt(t);for(let e of c){if(e.leaf.kind===`managed`||!Ut(e,Ht(u,n,e.modulePath)))continue;let o=Kt(e,t,r,i,a,n);o&&l.push(o)}let d=Bt(t);for(let e of c){if(e.leaf.kind!==`managed`)continue;let a=Ht(d,n,e.modulePath);if(!Ut(e,a))continue;let c=qt(e,t,r,a,i,o,s,n);c&&l.push(c)}return l}function Yt(e,t,n,r={}){return Se(n,()=>{let i=me(e,n),a=!!r.initMode,o=Jt(i,t,n,n.dryRun,r.templates,a,r.registryLookup,r.derivedPinLookup);if(!n.dryRun&&!n.updateDepsOnly&&!a){Ft(t,{version:3});let i={...r.rediscover?r.rediscover(t):n,dryRun:!0},a=Jt(me(e,i),t,i,!0,r.templates,!1,r.registryLookup,r.derivedPinLookup).filter(e=>e.path!==jt);if(a.length>0)throw new It(a[0])}return a&&!n.dryRun&&Ft(t,{version:3}),{changes:o}})}var Xt=[`root`,`block`,`model`,`ui`,`workflow`,`test`,`software`,`kind`],Zt=class extends Error{path;constructor(e,t){super(e),this.path=t,this.name=`DiscoveryError`}};function Qt(e){let t=new Set;for(let n of[e.dependencies,e.devDependencies,e.peerDependencies,e.optionalDependencies])if(n)for(let e of Object.keys(n))t.add(e);return t}function $t(e){return e===``||e===`.`}function en(e){let t=e.pkg[`block-scope`];if(typeof t==`string`){if(!Xt.includes(t))throw new Zt(`package.json "block-scope" must be one of ${Xt.join(`, `)}, got '${t}'`,e.path);return t}if($t(e.path))return`root`;if(e.pkg.block!==void 0)return`block`;let n=Qt(e.pkg);if(n.has(`@platforma-sdk/block-kind`))return`kind`;if(e.pkg[`block-software`]!==void 0)return`software`;if(n.has(`@platforma-sdk/package-builder`)){for(let e of n)if(/^@platforma-open\/.*runenv/.test(e))return`software`}if(n.has(`@platforma-sdk/workflow-tengo`))return`workflow`;if((n.has(`@platforma-sdk/ui-vue`)||n.has(`vue`))&&!e.pkg.main)return`ui`;if(n.has(`@platforma-sdk/model`)&&e.pkg.main)return`model`;if(n.has(`@platforma-sdk/test`))return`test`}function tn(e){let t=[];for(let n of e){let e=en(n);if(!e)throw new Zt(`Unclassified workspace package at '${n.path}'. Add a top-level "block-scope" string to its package.json.`,n.path);t.push({scope:e,name:n.pkg.name??n.path,path:$t(n.path)?``:n.path})}return t}function G(e,t){return e.modules.filter(e=>e.scope===t)}function nn(e,t){let n=G(e,t);if(n.length===0)throw Error(`findModule: expected one '${t}' module, found none`);if(n.length>1)throw Error(`findModule: expected exactly one '${t}' module, found ${n.length}`);return n[0]}function rn(e,t){return{[nn(e,t).name]:`workspace:*`}}function K(e,t){let n={};for(let r of G(e,t))n[r.name]=`workspace:*`;return n}function an(e){let t=e.facadeName,n=[{scope:`root`,name:t,path:``},{scope:`block`,name:`${t}.block`,path:`block`},{scope:`model`,name:`${t}.model`,path:`model`},{scope:`kind`,name:`${t}.kind`,path:`kind`},{scope:`ui`,name:`${t}.ui`,path:`ui`},{scope:`workflow`,name:`${t}.workflow`,path:`workflow`},{scope:`test`,name:`${t}.test`,path:`test`}];return e.softwarePlatform&&n.push({scope:`software`,name:`${t}.software`,path:`software`}),n}function on(e){return{isSdkInternal:e.isSdkInternal??!1,updateDepsOnly:e.updateDepsOnly??!1,modules:e.modules,blockVars:e.blockVars,version:e.version??0,dryRun:e.dryRun??!1}}var q=class extends Error{constructor(e){super(e),this.name=`StructureCliError`}};function sn(e,t){return e===``?t:`${e}/${t}`}function cn(e,t){try{return JSON.parse(e.read(t))}catch{return}}function ln(e){if(e.includes(`*`))throw new q(`pnpm-workspace.yaml 'packages:' entry '${e}' contains a glob. The structurer requires literal package paths — replace the glob with one entry per package directory.`);let t=e.replace(/^\.\//,``).replace(/\/$/,``);return t===`.`?``:t}function un(e){let t;try{t=e.read(`pnpm-workspace.yaml`)}catch{throw new q(`No pnpm-workspace.yaml found. This directory is empty or unrecognisable as a block — run 'block-tools structure init' instead, or pass --sdk-internal for an in-monorepo block.`)}let n=(0,s.parse)(t)??{},r=Array.isArray(n.packages)?n.packages:[],i=new Set([``]);for(let t of r){let n=ln(t);(n===``||e.exists(n))&&i.add(n)}let a=[];for(let t of i){let n=cn(e,sn(t,`package.json`));n&&a.push({path:t,pkg:n})}return a}function dn(e){let t=[],n=new Set([`node_modules`,`.turbo`,`dist`,`.git`,`block-pack`]);function r(i,a){let o=e.listDir(i);for(let s of o){if(!s.isDirectory||n.has(s.name))continue;let o=sn(i,s.name),c=cn(e,sn(o,`package.json`));c&&t.push({path:o,pkg:c}),a<2&&r(o,a+1)}}return r(``,1),t}function fn(e){let t=e.indexOf(`/`);if(!e.startsWith(`@`)||t<0)throw new q(`Cannot parse block name '${e}': expected '@npm-org/org-scope.short-name'.`);let n=e.slice(0,t),r=e.slice(t+1),i=r.indexOf(`.`);if(i<0)throw new q(`Cannot parse block name '${e}': base name '${r}' has no '.' separating org-scope from short-name.`);return{facadeName:e,baseName:r,npmOrg:n,orgScope:r.slice(0,i),shortName:r.slice(i+1)}}function pn(e){let{fs:t,isSdkInternal:n}=e,r=n?dn(t):un(t);if(r.length===0)throw new q(`No workspace packages found. Run 'block-tools structure init' to scaffold a block.`);let i=tn(r),a=Mt(t);Nt(a.version,0);let o=i.find(e=>e.scope===`block`)??i.find(e=>e.scope===`root`);if(!o)throw new q(`Could not find a 'block' (or root-as-block) package to derive BlockVars from.`);let s=o.name.replace(/\.block$/,``),c=fn(s);return i.some(e=>e.scope===`kind`)||i.push({scope:`kind`,name:`${s}.kind`,path:`kind`}),on({isSdkInternal:n,updateDepsOnly:e.updateDepsOnly??!1,modules:i,blockVars:c,version:a.version,dryRun:e.dryRun??!1})}var J=[`name`,`version`,`private`,`description`,`keywords`,`files`,`type`,`main`,`module`,`types`,`exports`,`scripts`,`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`,`devEngines`,`engines`,`packageManager`,`block`,`block-software`],Y=`1.0.0`;function X(){vt(`version`,e=>typeof e==`string`&&e.length>0?e:Y)}var mn=`24.22.1`,hn={name:`node`,version:mn,onFail:`download`},gn=`pnpm@12.16.1+sha512.091d1dee7927575661b25dab3c2ae31cafc1c54d6b71ed6a6600cf0c1cb10434a447eae14015f1b23e2e6bedeed79df94a932e2164d2832280dce3fb32f656d1`,_n=`~2.11.10`,vn=[`@milaboratories/*`,`@platforma-sdk/*`,`@platforma-open/*`],yn={"@milaboratories/pframes-rs-node":!0},bn={"@milaboratories/tengo-tester":!1,"cpu-features":!1,esbuild:!1,protobufjs:!1,ssh2:!1},xn={"build:dev-local":`cross-env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=local turbo run build`,"build:dev-remote":`cross-env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build`,"build:dev-no-software":`cross-env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=none turbo run build`,"build:dev-binary-existing":`cross-env PL_BUILD_CHANNEL=dev PL_BUILD_USE_PUBLISHED=true turbo run build`,"build:release":`cross-env PL_BUILD_CHANNEL=release PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build`},Sn={test:`cross-env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --concurrency 1`,"test:dry-run":`cross-env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --dry-run=json`};function Cn(){return{version:Y,private:!0,scripts:{fmt:`turbo run fmt`,check:`turbo run check`,...xn,...Sn,"mark-stable":`turbo run mark-stable`,"do-pack":`turbo run do-pack`,watch:`turbo watch build`,changeset:`changeset`,"version-packages":`changeset version`,"update-sdk":`block-tools structure refresh --update-deps-only`,"upgrade-sdk":`block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt`},peerDependencies:{oxlint:`*`,oxfmt:`*`},devDependencies:{"@changesets/cli":`catalog:`,"@milaboratories/ts-builder":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,"cross-env":`catalog:`,shx:`catalog:`,turbo:`catalog:`}}}function wn(){P(`packageManager`,gn),P(`devEngines.runtime`,hn),F(`pnpm`,e=>e===null||typeof e==`object`&&Object.values(e).every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===0)),st(`pnpm`,`pnpm 11+ ignores the "pnpm" field in package.json. Move its settings to pnpm-workspace.yaml: overrides as is, onlyBuiltDependencies as allowBuilds true, neverBuiltDependencies as allowBuilds false.`),F(`name`),I(`fmt`,`turbo run fmt`),I(`check`,`turbo run check`);for(let[e,t]of Object.entries(xn))I(e,t);for(let[e,t]of Object.entries(Sn))I(e,t);L(`build`),L(`build:dev`),I(`mark-stable`,`turbo run mark-stable`),I(`do-pack`,`turbo run do-pack`),I(`watch`,`turbo watch build`),I(`changeset`,`changeset`),I(`version-packages`,`changeset version`),I(`update-sdk`,`block-tools structure refresh --update-deps-only`),L(`update`),I(`upgrade-sdk`,`block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt`),V({"@changesets/cli":`catalog:`,"@milaboratories/ts-builder":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,"cross-env":`catalog:`,shx:`catalog:`,turbo:`catalog:`}),H({oxlint:`*`,oxfmt:`*`}),ht((e,t)=>{if(!/^(\/\/|--)/.test(e)||typeof t!=`object`||!t)return!1;let n=t;return n.pnpm!==void 0||n.overrides!==void 0}),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}var Tn=`https://turbo.build/schema.json`,En=[`tsconfig.json`],Dn={fmt:{cache:!1},check:{dependsOn:[`^build`],outputs:[]},build:{dependsOn:[`^build`,`check`],inputs:[`$TURBO_DEFAULT$`],env:[`PL_DOCKER_REGISTRY_PUSH_TO`,`PL_BUILD_CHANNEL`,`PL_BUILD_VARIANT`,`PL_BUILD_LOCATION`,`PL_BUILD_USE_PUBLISHED`,`PL_DEV_DOCKER_PUSH_URL`,`PL_DEV_DOCKER_PULL_URL`,`PL_DEV_BINARY_UPLOAD_URL`,`PL_RELEASE_DOCKER_PUSH_URL`,`PL_RELEASE_DOCKER_PULL_URL`,`PL_RELEASE_BINARY_UPLOAD_URL`,`PL_REGISTRY_PLATFORMA_OPEN_UPLOAD_URL`],passThroughEnv:[`AWS_*`,`PL_AWS_*`],outputs:[`./dist/**`,`./block-pack/**`,`./pkg-*.tgz`]},"do-pack":{dependsOn:[`build`],outputs:[`package.tgz`]},test:{dependsOn:[`build`,`check`],passThroughEnv:[`PL_ADDRESS`,`PL_TEST_PASSWORD`,`PL_TEST_USER`,`PL_TEST_PROXY`,`DEBUG`]},"mark-stable":{passThroughEnv:[`PL_REGISTRY`,`AWS_*`],cache:!1}};function On(){return{$schema:Tn,globalDependencies:En,tasks:{...Dn}}}function kn(){P(`$schema`,Tn),P(`globalDependencies`,En),ct(`tasks`,Dn),F(`tasks.build:dev`),U([`$schema`,`globalDependencies`,`tasks`])}var An=2,jn=500,Mn=3e4;function Nn(e){if(!e)return null;let t=Number(e);if(Number.isFinite(t)&&t>0)return t*1e3;let n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,n-Date.now())}async function Pn(e){for(let t=1;;t++){let n;try{n=await fetch(e,{signal:AbortSignal.timeout(Mn)})}catch(e){if(t>An)throw e;let n=jn*2**(t-1)*(.8+.4*Math.random());await(0,c.setTimeout)(n);continue}if(n.ok)return n;if(!(n.status===429||n.status>=500)||t>An)throw Error(`registry returned HTTP ${n.status}`);let r=Nn(n.headers.get(`retry-after`));if(r!=null){await(0,c.setTimeout)(r);continue}let i=jn*2**(t-1)*(.8+.4*Math.random());await(0,c.setTimeout)(i)}}function Fn(){return{async getLatestVersion(e){let t=(await(await Pn(`https://registry.npmjs.org/-/package/${e}/dist-tags`)).json()).latest;if(!t)throw Error(`no 'latest' dist-tag in registry response`);return t},async getDeclaredDependency(e,t,n){let r=await(await Pn(`https://registry.npmjs.org/${e}/${t}`)).json();return r.dependencies?.[n]??r.peerDependencies?.[n]}}}async function In(e,t){let n=await Promise.all(t.map(async t=>[t,await e.getLatestVersion(t)]));return new Map(n)}function Ln(e){return t=>e.get(t)}var Rn=[/^@platforma-sdk\//,/^@milaboratories\//];function zn(e){return Rn.some(t=>t.test(e))}async function Bn(e,t=Fn()){return e.length===0?()=>void 0:Ln(await In(t,e))}function Vn(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e)}async function Hn(e,t=Fn()){if(e.length===0)return()=>void 0;let n=await Promise.all(e.map(async e=>{let n=await t.getDeclaredDependency(e.of,e.ofVersion??`latest`,e.entry);if(n===void 0)throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion?`@${e.ofVersion}`:` (latest)`} declares no dependency '${e.entry}'. A derived pin requires the source to declare the dep as an exact version.`);if(!Vn(n))throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion?`@${e.ofVersion}`:` (latest)`} declares '${e.entry}: ${n}', which is not an exact version. A derived pin requires an exact ('x.y.z') source dependency so the catalog can pin to it precisely.`);return[e.entry,n]})),r=new Map(n);return e=>r.get(e)}var Un=[`vite`,`tsup`,`vue-tsc`,`@vitejs/plugin-vue`,`vite-plugin-dts`,`@platforma-sdk/eslint-config`];function Wn(){for(let e of Un)B(e)}var Z=[`@platforma-sdk/model`,`@platforma-sdk/ui-vue`,`@platforma-sdk/workflow-tengo`,`@platforma-sdk/test`,`@platforma-sdk/block-kind`,`@platforma-sdk/block-tools`,`@platforma-sdk/block-kind`,`@platforma-sdk/tengo-builder`,`@platforma-sdk/package-builder`,`@milaboratories/ts-builder`,`@milaboratories/ts-configs`],Gn=`0.0.0-init-must-fetch`;for(let e of Z)if(!zn(e))throw Error(`SDK_CATALOG_PACKAGES entry '${e}' matches no catalog bump pattern; its placeholder would never be resolved to npm latest on init. Add it to CATALOG_BUMP_PATTERNS or move it to the infra floor.`);var Kn={turbo:_n,shx:`~0.4.0`,"cross-env":`~10.1.0`,"@changesets/cli":`~2.29.8`,vitest:`~4.0.18`,typescript:`~5.9.3`},qn=[{entry:`vue`,of:`@platforma-sdk/ui-vue`},{entry:`@milaboratories/helpers`,of:`@platforma-sdk/model`}],Jn=`@platforma-open/milaboratories.runenv-python-3`,Yn=`1.8.2`;function Xn(e){let t=e.modules.filter(e=>e.path!==``).map(e=>e.path).sort(),n={};for(let e of Z)n[e]=Gn;return Object.assign(n,Kn),e.modules.some(e=>e.scope===`software`)&&(n[Jn]=Yn),{packages:t,catalog:n}}function Zn(){yt(),Dt(`minimumReleaseAgeExclude`,vn),Et(`allowBuilds`,bn,{keepExisting:!0}),Et(`allowBuilds`,yn);for(let[e,t]of Object.entries(Kn))xt(e,t);wt(`turbo`,_n);for(let e of Un)Tt(e)}var Qn=[`.test_auth.json`,`node_modules/`,`dist/`,`block-pack/`,`dev/`,`work/`,`log/`,`.turbo`,`vite.config.*.timestamp-*`,`software/**/*.tgz`,`.DS_Store`,`.vscode/sftp.json`,`test-dry-run.json`];function $n(){Ot(Qn)}var er=`---
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
Initial release.
|
|
16
|
-
`;function tr(e){return{$schema:`https://unpkg.com/@changesets/config@3.1.1/schema.json`,changelog:rr,commit:!1,fixed:[lr(e)],linked:[],access:ir,baseBranch:ar,updateInternalDependencies:or,ignore:[]}}function nr(e){N(`changelog`,rr),N(`commit`,!1),N(`access`,ir),N(`baseBranch`,ar),N(`updateInternalDependencies`,or);let t=lr(e);vt(`fixed`,e=>ur(e,t)),U(sr)}var rr=`@changesets/cli/changelog`,ir=`restricted`,ar=`main`,or=`patch`,sr=[`$schema`,`changelog`,`commit`,`fixed`,`linked`,`access`,`baseBranch`,`updateInternalDependencies`,`ignore`],cr=[`block`,`model`,`ui`,`workflow`];function lr(e){return cr.flatMap(t=>G(e,t).map(e=>e.name))}function ur(e,t){let n=new Set(t),r=Array.isArray(e)?e.filter(dr):[],i=r.findIndex(e=>e.some(e=>n.has(e))),a=[];return r.forEach((e,r)=>{let o=e.filter(e=>!n.has(e));r===i?a.push([...t,...o]):o.length>0&&a.push(o)}),i===-1&&a.push(t),a}function dr(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function fr(){g(`root`,()=>{_(({ctx:e})=>!e.isSdkInternal,()=>{b(`turbo.json`,D(()=>On()),()=>{kn()}),y(`.vscode/settings.json`,w(`root/.vscode/settings.json`)),b(`package.json`,D(()=>Cn()),()=>{wn()}),b(`pnpm-workspace.yaml`,D(e=>Xn(e)),()=>{Zn()}),b(`.gitignore`,w(`root/gitignore`),()=>{$n()}),b(`.changeset/config.json`,D(e=>tr(e)),e=>{nr(e)}),S(`.changeset/scaffold.md`,T(er))})})}function pr(e){return e.split(/[-_]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function mr(){g(`root`,()=>{_(({ctx:e})=>!e.isSdkInternal,()=>{y(`.github/workflows/build.yaml`,E(`workflows/build.tpl.yaml`,e=>{let t=e.blockVars.shortName;return{appName:`Block: ${pr(t)}`,appNameSlug:`block-${t}`,nodeVersion:mn}})),y(`.github/workflows/mark-stable.yaml`,E(`workflows/mark-stable.tpl.yaml`,e=>({appName:`Block: ${pr(e.blockVars.shortName)} - Mark Stable`,nodeVersion:mn})))})})}var hr={"@platforma-open":{s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://blocks.pl-open.science`},"@milaboratories":{s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://block.registry.platforma.bio/releases`}},gr={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://blocks.pl-open.science`},_r={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1`,serveUrl:`https://aux-blocks.pl-open.science`};function vr(e,t){let n=t?_r:hr[e]??gr;return`block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`}function yr(e){let t={};for(let n of G(e,`workflow`))t.workflow=`${n.name}/dist/tengo/tpl/main.plj.gz`;for(let n of G(e,`model`))t.model=`${n.name}/dist/model.json`;for(let n of G(e,`ui`))t.ui=`${n.name}/dist`;return t}function br(e,t){return{build:`ts-builder build --target block-facade && block-tools pack`,check:`ts-builder type-check --target block-facade`,prepublishOnly:vr(e,t),"do-pack":`shx rm -f package.tgz && pnpm pack && shx mv *.tgz package.tgz`}}var xr={"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,"@platforma-sdk/model":`sdk:`,shx:`catalog:`,typescript:`catalog:`},Sr={".":{sources:`./src/index.ts`,types:`./dist/index.d.ts`,default:`./dist/index.js`}};function Cr(e){if(Object.keys(e.components).length===0)throw Error(`block.components is empty — no workflow/model/ui module was discovered`);let t=e.meta,n=[[`block.meta.title`,t.title],[`block.meta.description`,t.description],[`block.meta.logo`,t.logo],[`block.meta.organization.name`,t.organization?.name],[`block.meta.organization.url`,t.organization?.url],[`block.meta.organization.logo`,t.organization?.logo]];for(let[e,t]of n)if(typeof t!=`string`||t===``)throw Error(`required block field '${e}' is empty`)}function wr(e){let t=e.blockVars,n={...xr,...K(e,`model`),...K(e,`ui`),...K(e,`workflow`),...K(e,`kind`)},r={components:yr(e),meta:{title:t.shortName,description:`${t.shortName} block`,logo:`file:logos/block-logo.png`,organization:{name:t.orgScope,url:`https://example.com`,logo:`file:logos/organization-logo.png`}}};return Cr(r),{name:`${t.facadeName}.block`,version:Y,type:`module`,files:[`dist`,`block-pack`],main:`./dist/index.js`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:Sr,scripts:br(t.npmOrg,e.isSdkInternal),dependencies:{},devDependencies:n,block:r}}function Tr(e){let t=e.blockVars,n=G(e,`kind`);if(n.length!==1)throw Error(n.length===0?`block '${t.facadeName}' declares no kind — every block must have a sibling kind/ package`:`block '${t.facadeName}' declares ${n.length} kinds; exactly one is required`);N(`type`,`module`),N(`files`,[`dist`,`block-pack`]),N(`main`,`./dist/index.js`),N(`module`,`./dist/index.js`),N(`types`,`./dist/index.d.ts`),N(`exports`,Sr);let r=br(t.npmOrg,e.isSdkInternal);for(let[e,t]of Object.entries(r))F(e,t);H(`model`),H(`ui`),H(`workflow`),H(`kind`),R(`@milaboratories/ts-builder`,`sdk:`),R(`@milaboratories/ts-configs`,`sdk:`),R(`@platforma-sdk/block-tools`,`sdk:`),R(`@platforma-sdk/model`,`sdk:`),R(`shx`,`catalog:`),R(`typescript`,`catalog:`),N(`block.components`,yr(e)),st(`version`,`facade package.json must carry a 'version' (the facade publishes)`),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Er(e){let t=e.split(/[^A-Za-z0-9]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return/^[0-9]/.test(t)?`_${t}`:t}function Dr(){g(`block`,()=>{C(`index.js`),C(`index.d.ts`),y(`src/index.ts`,E(`block/src/index.tpl.ts`,e=>({facadeName:e.blockVars.facadeName,pascalName:Er(e.blockVars.shortName)}))),y(`src/AGENTS.ts`,w(`block/src/AGENTS.ts`)),x(`src/block-extra.ts`,w(`block/src/block-extra.ts`)),x(`src/agents-extra.ts`,w(`block/src/agents-extra.ts`)),y(`tsconfig.json`,w(`block/tsconfig.json`)),S(`logos/block-logo.png`,Me(`block/logos/block-logo.png`)),S(`logos/organization-logo.png`,Me(`block/logos/organization-logo.png`)),b(`package.json`,D(e=>wr(e)),e=>{Tr(e)})})}var Q=`src/**/*.test.ts`,Or=`src/**/*.test.tengo`;function kr(e){return{name:`${e.blockVars.facadeName}.model`,version:Y,private:!0,type:`module`,main:`dist/index.cjs`,module:`dist/index.js`,types:`dist/index.d.ts`,exports:{".":{types:`./dist/index.d.ts`,sources:`./src/index.ts`,import:`./dist/index.js`},"./dist/*":`./dist/*`},scripts:{fmt:`ts-builder format`,watch:`ts-builder build --target block-model --watch`,build:`ts-builder build --target block-model && block-tools build-model`,check:`ts-builder check --target block-model`},dependencies:{"@platforma-sdk/model":`sdk:`,...K(e,`kind`)},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Ar(){X(),N(`private`,!0),N(`type`,`module`),N(`main`,`dist/index.cjs`),N(`module`,`dist/index.js`),N(`types`,`dist/index.d.ts`),N(`exports`,{".":{types:`./dist/index.d.ts`,sources:`./src/index.ts`,import:`./dist/index.js`},"./dist/*":`./dist/*`}),F(`fmt`,`ts-builder format`),F(`watch`,`ts-builder build --target block-model --watch`),F(`build`,`ts-builder build --target block-model && block-tools build-model`),F(`check`,`ts-builder check --target block-model`),L(`@platforma-sdk/model`,`sdk:`),mt(`kind`),B({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`}),V({"@types/node":`*`,typescript:`*`}),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{F(`test`,`vitest run --passWithNoTests`),R(`vitest`,`catalog:`),R(`@types/node`,`*`)},()=>z(`vitest`))),Wn(),P(`tsup`),I(`lint`),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function jr(){g(`model`,()=>{_(v(Q),()=>y(`tsconfig.json`,w(`model/tsconfig.node.json`)),()=>y(`tsconfig.json`,w(`model/tsconfig.json`))),y(`.oxlintrc.json`,w(`model/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`model/.oxfmtrc.json`)),S(`src/index.ts`,E(`model/src/index.tpl.ts`,e=>({kindPkg:`${e.blockVars.facadeName}.kind`}))),b(`package.json`,D(e=>kr(e)),()=>{Ar()})})}var Mr={".":{types:`./dist/index.d.ts`,sources:`./src/index.ts`,import:`./dist/index.js`,require:`./dist/index.cjs`,default:`./dist/index.js`}};function Nr(e){return{name:`${e.blockVars.facadeName}.kind`,version:Y,private:!0,type:`module`,main:`./dist/index.cjs`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:Mr,scripts:{fmt:`ts-builder format`,watch:`ts-builder build --target block-kind --watch`,build:`ts-builder build --target block-kind && block-tools build-kind-manifest`,check:`ts-builder check --target block-kind`},dependencies:{"@platforma-sdk/block-kind":`sdk:`},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Pr(){X(),N(`private`,!0),N(`type`,`module`),N(`main`,`./dist/index.cjs`),N(`module`,`./dist/index.js`),N(`types`,`./dist/index.d.ts`),N(`exports`,Mr),F(`fmt`,`ts-builder format`),F(`watch`,`ts-builder build --target block-kind --watch`),F(`build`,`ts-builder build --target block-kind && block-tools build-kind-manifest`),F(`check`,`ts-builder check --target block-kind`),I(`lint`),L(`@platforma-sdk/block-kind`,`sdk:`),B({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`}),V({"@types/node":`*`,typescript:`*`}),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Fr(){g(`kind`,()=>{y(`tsconfig.json`,w(`kind/tsconfig.json`)),y(`.oxlintrc.json`,w(`kind/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`kind/.oxfmtrc.json`)),x(`src/index.ts`,w(`kind/src/index.ts`)),b(`package.json`,D(e=>Nr(e)),()=>{Pr()})})}function Ir(e){return{name:`${e.blockVars.facadeName}.ui`,version:Y,private:!0,type:`module`,scripts:{fmt:`ts-builder format`,dev:`ts-builder serve --target block-ui`,watch:`ts-builder build --target block-ui --watch`,build:`ts-builder build --target block-ui`,check:`ts-builder check --target block-ui`},dependencies:{"@platforma-sdk/ui-vue":`sdk:`,vue:`catalog:`,...rn(e,`model`)},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Lr(){X(),N(`private`,!0),N(`type`,`module`),F(`fmt`,`ts-builder format`),F(`dev`,`ts-builder serve --target block-ui`),F(`watch`,`ts-builder build --target block-ui --watch`),F(`build`,`ts-builder build --target block-ui`),F(`check`,`ts-builder check --target block-ui`),L(`@platforma-sdk/ui-vue`,`sdk:`),L(`vue`,`catalog:`),mt(`model`),B({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`}),Wn(),I(`preview`),I(`lint`),V({"@types/node":`*`,typescript:`*`}),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{F(`test`,`vitest run --passWithNoTests`),R(`vitest`,`catalog:`),R(`@types/node`,`*`)},()=>z(`vitest`))),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Rr(){g(`ui`,()=>{_(v(Q),()=>y(`tsconfig.json`,w(`ui/tsconfig.node.json`)),()=>y(`tsconfig.json`,w(`ui/tsconfig.json`))),y(`.oxlintrc.json`,w(`ui/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`ui/.oxfmtrc.json`)),x(`index.html`,w(`ui/index.html`)),S(`src/main.ts`,w(`ui/src/main.ts`)),S(`src/app.ts`,E(`ui/src/app.tpl.ts`,e=>({modelPkg:`${e.blockVars.facadeName}.model`}))),S(`src/MainPage.vue`,E(`ui/src/MainPage.tpl.vue`,e=>({shortName:e.blockVars.shortName}))),b(`package.json`,D(e=>Ir(e)),()=>{Lr()})})}function zr(e){return{name:`${e.blockVars.facadeName}.workflow`,version:Y,private:!0,type:`module`,scripts:{build:`shx rm -rf dist && pl-tengo build`,check:`pl-tengo imports && pl-tengo check`,format:`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`},dependencies:{"@platforma-sdk/workflow-tengo":`sdk:`,...K(e,`software`)},devDependencies:{"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}}}function Br(){X(),N(`private`,!0),N(`type`,`module`),F(`build`,`shx rm -rf dist && pl-tengo build`),F(`check`,`pl-tengo imports && pl-tengo check`),F(`format`,`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{_(v(Or),()=>F(`test`,`pl-tengo test && vitest run --passWithNoTests`),()=>F(`test`,`vitest run --passWithNoTests`)),B({vitest:`catalog:`})},()=>{_(v(Or),()=>F(`test`,`pl-tengo test`)),z(`vitest`)})),L(`@platforma-sdk/workflow-tengo`,`sdk:`),mt(`software`),B({"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}),Wn(),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Vr(){g(`workflow`,()=>{y(`format.el`,w(`workflow/format.el`)),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{y(`tsconfig.json`,w(`workflow/tsconfig.json`)),x(`vitest.config.mts`,w(`workflow/vitest.config.mts`))},()=>{C(`tsconfig.json`),C(`vitest.config.mts`)})),C(`index.js`),C(`index.d.ts`),S(`src/main.tpl.tengo`,E(`workflow/src/main.tpl.tengo`,e=>({shortName:e.blockVars.shortName}))),b(`package.json`,D(e=>zr(e)),()=>{Br()})})}function Hr(e){return{name:`${e.blockVars.facadeName}.test`,version:Y,private:!0,type:`module`,scripts:{fmt:`ts-builder format`,check:`ts-builder check --target block-test`,test:`vitest run --passWithNoTests`},peerDependencies:{typescript:`*`},devDependencies:{"@platforma-sdk/test":`sdk:`,"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,vitest:`catalog:`}}}function Ur(){X(),N(`private`,!0),N(`type`,`module`),F(`fmt`,`ts-builder format`),F(`check`,`ts-builder check --target block-test`),F(`test`,`vitest run --passWithNoTests`),I(`lint`),B({"@platforma-sdk/test":`sdk:`,"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,vitest:`catalog:`}),V({typescript:`*`}),z(`@types/node`),Wn(),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Wr(){g(`test`,()=>{y(`tsconfig.json`,w(`test/tsconfig.json`)),y(`.oxlintrc.json`,w(`test/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`test/.oxfmtrc.json`)),x(`vitest.config.mts`,w(`test/vitest.config.mts`)),S(`src/demo.test.ts`,T(`import { expect, test } from "vitest";
|
|
16
|
+
`;function tr(e){return{$schema:`https://unpkg.com/@changesets/config@3.1.1/schema.json`,changelog:rr,commit:!1,fixed:[lr(e)],linked:[],access:ir,baseBranch:ar,updateInternalDependencies:or,ignore:[]}}function nr(e){P(`changelog`,rr),P(`commit`,!1),P(`access`,ir),P(`baseBranch`,ar),P(`updateInternalDependencies`,or);let t=lr(e);vt(`fixed`,e=>ur(e,t)),U(sr)}var rr=`@changesets/cli/changelog`,ir=`restricted`,ar=`main`,or=`patch`,sr=[`$schema`,`changelog`,`commit`,`fixed`,`linked`,`access`,`baseBranch`,`updateInternalDependencies`,`ignore`],cr=[`block`,`model`,`ui`,`workflow`];function lr(e){return cr.flatMap(t=>G(e,t).map(e=>e.name))}function ur(e,t){let n=new Set(t),r=Array.isArray(e)?e.filter(dr):[],i=r.findIndex(e=>e.some(e=>n.has(e))),a=[];return r.forEach((e,r)=>{let o=e.filter(e=>!n.has(e));r===i?a.push([...t,...o]):o.length>0&&a.push(o)}),i===-1&&a.push(t),a}function dr(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function fr(){g(`root`,()=>{_(({ctx:e})=>!e.isSdkInternal,()=>{b(`turbo.json`,D(()=>On()),()=>{kn()}),y(`.vscode/settings.json`,w(`root/.vscode/settings.json`)),b(`package.json`,D(()=>Cn()),()=>{wn()}),b(`pnpm-workspace.yaml`,D(e=>Xn(e)),()=>{Zn()}),b(`.gitignore`,w(`root/gitignore`),()=>{$n()}),b(`.changeset/config.json`,D(e=>tr(e)),e=>{nr(e)}),S(`.changeset/scaffold.md`,T(er))})})}function pr(e){return e.split(/[-_]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function mr(){g(`root`,()=>{_(({ctx:e})=>!e.isSdkInternal,()=>{y(`.github/workflows/build.yaml`,E(`workflows/build.tpl.yaml`,e=>{let t=e.blockVars.shortName;return{appName:`Block: ${pr(t)}`,appNameSlug:`block-${t}`,nodeVersion:mn}})),y(`.github/workflows/mark-stable.yaml`,E(`workflows/mark-stable.tpl.yaml`,e=>({appName:`Block: ${pr(e.blockVars.shortName)} - Mark Stable`,nodeVersion:mn})))})})}var hr={"@platforma-open":{s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://blocks.pl-open.science`},"@milaboratories":{s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://block.registry.platforma.bio/releases`}},gr={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://blocks.pl-open.science`},_r={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1`,serveUrl:`https://aux-blocks.pl-open.science`};function vr(e,t){let n=t?_r:hr[e]??gr;return`block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`}function yr(e){let t={};for(let n of G(e,`workflow`))t.workflow=`${n.name}/dist/tengo/tpl/main.plj.gz`;for(let n of G(e,`model`))t.model=`${n.name}/dist/model.json`;for(let n of G(e,`ui`))t.ui=`${n.name}/dist`;return t}function br(e,t){return{build:`ts-builder build --target block-facade && block-tools pack`,check:`ts-builder type-check --target block-facade`,prepublishOnly:vr(e,t),"do-pack":`shx rm -f package.tgz && pnpm pack && shx mv *.tgz package.tgz`}}var xr={"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,"@platforma-sdk/model":`sdk:`,shx:`catalog:`,typescript:`catalog:`},Sr={".":{sources:`./src/index.ts`,types:`./dist/index.d.ts`,default:`./dist/index.js`}};function Cr(e){if(Object.keys(e.components).length===0)throw Error(`block.components is empty — no workflow/model/ui module was discovered`);let t=e.meta,n=[[`block.meta.title`,t.title],[`block.meta.description`,t.description],[`block.meta.logo`,t.logo],[`block.meta.organization.name`,t.organization?.name],[`block.meta.organization.url`,t.organization?.url],[`block.meta.organization.logo`,t.organization?.logo]];for(let[e,t]of n)if(typeof t!=`string`||t===``)throw Error(`required block field '${e}' is empty`)}function wr(e){let t=e.blockVars,n={...xr,...K(e,`model`),...K(e,`ui`),...K(e,`workflow`),...K(e,`kind`)},r={components:yr(e),meta:{title:t.shortName,description:`${t.shortName} block`,logo:`file:logos/block-logo.png`,organization:{name:t.orgScope,url:`https://example.com`,logo:`file:logos/organization-logo.png`}}};return Cr(r),{name:`${t.facadeName}.block`,version:Y,type:`module`,files:[`dist`,`block-pack`],main:`./dist/index.js`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:Sr,scripts:br(t.npmOrg,e.isSdkInternal),dependencies:{},devDependencies:n,block:r}}function Tr(e){let t=e.blockVars,n=G(e,`kind`);if(n.length!==1)throw Error(n.length===0?`block '${t.facadeName}' declares no kind — every block must have a sibling kind/ package`:`block '${t.facadeName}' declares ${n.length} kinds; exactly one is required`);P(`type`,`module`),P(`files`,[`dist`,`block-pack`]),P(`main`,`./dist/index.js`),P(`module`,`./dist/index.js`),P(`types`,`./dist/index.d.ts`),P(`exports`,Sr);let r=br(t.npmOrg,e.isSdkInternal);for(let[e,t]of Object.entries(r))I(e,t);mt(`model`),mt(`ui`),mt(`workflow`),mt(`kind`),z(`@milaboratories/ts-builder`,`sdk:`),z(`@milaboratories/ts-configs`,`sdk:`),z(`@platforma-sdk/block-tools`,`sdk:`),z(`@platforma-sdk/model`,`sdk:`),z(`shx`,`catalog:`),z(`typescript`,`catalog:`),P(`block.components`,yr(e)),ot(`version`,`facade package.json must carry a 'version' (the facade publishes)`),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Er(e){let t=e.split(/[^A-Za-z0-9]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return/^[0-9]/.test(t)?`_${t}`:t}function Dr(){g(`block`,()=>{C(`index.js`),C(`index.d.ts`),y(`src/index.ts`,E(`block/src/index.tpl.ts`,e=>({facadeName:e.blockVars.facadeName,pascalName:Er(e.blockVars.shortName)}))),y(`src/AGENTS.ts`,w(`block/src/AGENTS.ts`)),x(`src/block-extra.ts`,w(`block/src/block-extra.ts`)),x(`src/agents-extra.ts`,w(`block/src/agents-extra.ts`)),y(`tsconfig.json`,w(`block/tsconfig.json`)),S(`logos/block-logo.png`,Me(`block/logos/block-logo.png`)),S(`logos/organization-logo.png`,Me(`block/logos/organization-logo.png`)),b(`package.json`,D(e=>wr(e)),e=>{Tr(e)})})}var Q=`src/**/*.test.ts`,Or=`src/**/*.test.tengo`;function kr(e){return{name:`${e.blockVars.facadeName}.model`,version:Y,private:!0,type:`module`,main:`dist/index.cjs`,module:`dist/index.js`,types:`dist/index.d.ts`,exports:{".":{types:`./dist/index.d.ts`,sources:`./src/index.ts`,import:`./dist/index.js`},"./dist/*":`./dist/*`},scripts:{fmt:`ts-builder format`,watch:`ts-builder build --target block-model --watch`,build:`ts-builder build --target block-model && block-tools build-model`,check:`ts-builder check --target block-model`},dependencies:{"@platforma-sdk/model":`sdk:`,...K(e,`kind`)},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Ar(){X(),P(`private`,!0),P(`type`,`module`),P(`main`,`dist/index.cjs`),P(`module`,`dist/index.js`),P(`types`,`dist/index.d.ts`),P(`exports`,{".":{types:`./dist/index.d.ts`,sources:`./src/index.ts`,import:`./dist/index.js`},"./dist/*":`./dist/*`}),I(`fmt`,`ts-builder format`),I(`watch`,`ts-builder build --target block-model --watch`),I(`build`,`ts-builder build --target block-model && block-tools build-model`),I(`check`,`ts-builder check --target block-model`),R(`@platforma-sdk/model`,`sdk:`),pt(`kind`),V({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`}),H({"@types/node":`*`,typescript:`*`}),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{I(`test`,`vitest run --passWithNoTests`),z(`vitest`,`catalog:`),z(`@types/node`,`*`)},()=>B(`vitest`))),Wn(),F(`tsup`),L(`lint`),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function jr(){g(`model`,()=>{_(v(Q),()=>y(`tsconfig.json`,w(`model/tsconfig.node.json`)),()=>y(`tsconfig.json`,w(`model/tsconfig.json`))),y(`.oxlintrc.json`,w(`model/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`model/.oxfmtrc.json`)),S(`src/index.ts`,E(`model/src/index.tpl.ts`,e=>({kindPkg:`${e.blockVars.facadeName}.kind`}))),b(`package.json`,D(e=>kr(e)),()=>{Ar()})})}var Mr={".":{types:`./dist/index.d.ts`,sources:`./src/index.ts`,import:`./dist/index.js`,require:`./dist/index.cjs`,default:`./dist/index.js`}};function Nr(e){return{name:`${e.blockVars.facadeName}.kind`,version:Y,private:!0,type:`module`,main:`./dist/index.cjs`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:Mr,scripts:{fmt:`ts-builder format`,watch:`ts-builder build --target block-kind --watch`,build:`ts-builder build --target block-kind && block-tools build-kind-manifest`,check:`ts-builder check --target block-kind`},dependencies:{"@platforma-sdk/block-kind":`sdk:`},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Pr(){X(),P(`private`,!0),P(`type`,`module`),P(`main`,`./dist/index.cjs`),P(`module`,`./dist/index.js`),P(`types`,`./dist/index.d.ts`),P(`exports`,Mr),I(`fmt`,`ts-builder format`),I(`watch`,`ts-builder build --target block-kind --watch`),I(`build`,`ts-builder build --target block-kind && block-tools build-kind-manifest`),I(`check`,`ts-builder check --target block-kind`),L(`lint`),R(`@platforma-sdk/block-kind`,`sdk:`),V({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`}),H({"@types/node":`*`,typescript:`*`}),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Fr(){g(`kind`,()=>{y(`tsconfig.json`,w(`kind/tsconfig.json`)),y(`.oxlintrc.json`,w(`kind/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`kind/.oxfmtrc.json`)),x(`src/index.ts`,w(`kind/src/index.ts`)),b(`package.json`,D(e=>Nr(e)),()=>{Pr()})})}function Ir(e){return{name:`${e.blockVars.facadeName}.ui`,version:Y,private:!0,type:`module`,scripts:{fmt:`ts-builder format`,dev:`ts-builder serve --target block-ui`,watch:`ts-builder build --target block-ui --watch`,build:`ts-builder build --target block-ui`,check:`ts-builder check --target block-ui`},dependencies:{"@platforma-sdk/ui-vue":`sdk:`,vue:`catalog:`,...rn(e,`model`)},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Lr(){X(),P(`private`,!0),P(`type`,`module`),I(`fmt`,`ts-builder format`),I(`dev`,`ts-builder serve --target block-ui`),I(`watch`,`ts-builder build --target block-ui --watch`),I(`build`,`ts-builder build --target block-ui`),I(`check`,`ts-builder check --target block-ui`),R(`@platforma-sdk/ui-vue`,`sdk:`),R(`vue`,`catalog:`),pt(`model`),V({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`}),Wn(),L(`preview`),L(`lint`),H({"@types/node":`*`,typescript:`*`}),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{I(`test`,`vitest run --passWithNoTests`),z(`vitest`,`catalog:`),z(`@types/node`,`*`)},()=>B(`vitest`))),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Rr(){g(`ui`,()=>{_(v(Q),()=>y(`tsconfig.json`,w(`ui/tsconfig.node.json`)),()=>y(`tsconfig.json`,w(`ui/tsconfig.json`))),y(`.oxlintrc.json`,w(`ui/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`ui/.oxfmtrc.json`)),x(`index.html`,w(`ui/index.html`)),S(`src/main.ts`,w(`ui/src/main.ts`)),S(`src/app.ts`,E(`ui/src/app.tpl.ts`,e=>({modelPkg:`${e.blockVars.facadeName}.model`}))),S(`src/MainPage.vue`,E(`ui/src/MainPage.tpl.vue`,e=>({shortName:e.blockVars.shortName}))),b(`package.json`,D(e=>Ir(e)),()=>{Lr()})})}function zr(e){return{name:`${e.blockVars.facadeName}.workflow`,version:Y,private:!0,type:`module`,scripts:{build:`shx rm -rf dist && pl-tengo build`,check:`pl-tengo imports && pl-tengo check`,format:`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`},dependencies:{"@platforma-sdk/workflow-tengo":`sdk:`,...K(e,`software`)},devDependencies:{"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}}}function Br(){X(),P(`private`,!0),P(`type`,`module`),I(`build`,`shx rm -rf dist && pl-tengo build`),I(`check`,`pl-tengo imports && pl-tengo check`),I(`format`,`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{_(v(Or),()=>I(`test`,`pl-tengo test && vitest run --passWithNoTests`),()=>I(`test`,`vitest run --passWithNoTests`)),V({vitest:`catalog:`})},()=>{_(v(Or),()=>I(`test`,`pl-tengo test`)),B(`vitest`)})),R(`@platforma-sdk/workflow-tengo`,`sdk:`),pt(`software`),V({"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}),Wn(),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Vr(){g(`workflow`,()=>{y(`format.el`,w(`workflow/format.el`)),_(({ctx:e})=>!e.isSdkInternal,()=>_(v(Q),()=>{y(`tsconfig.json`,w(`workflow/tsconfig.json`)),x(`vitest.config.mts`,w(`workflow/vitest.config.mts`))},()=>{C(`tsconfig.json`),C(`vitest.config.mts`)})),C(`index.js`),C(`index.d.ts`),S(`src/main.tpl.tengo`,E(`workflow/src/main.tpl.tengo`,e=>({shortName:e.blockVars.shortName}))),b(`package.json`,D(e=>zr(e)),()=>{Br()})})}function Hr(e){return{name:`${e.blockVars.facadeName}.test`,version:Y,private:!0,type:`module`,scripts:{fmt:`ts-builder format`,check:`ts-builder check --target block-test`,test:`vitest run --passWithNoTests`},peerDependencies:{typescript:`*`},devDependencies:{"@platforma-sdk/test":`sdk:`,"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,vitest:`catalog:`}}}function Ur(){X(),P(`private`,!0),P(`type`,`module`),I(`fmt`,`ts-builder format`),I(`check`,`ts-builder check --target block-test`),I(`test`,`vitest run --passWithNoTests`),L(`lint`),V({"@platforma-sdk/test":`sdk:`,"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,vitest:`catalog:`}),H({typescript:`*`}),B(`@types/node`),Wn(),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}function Wr(){g(`test`,()=>{y(`tsconfig.json`,w(`test/tsconfig.json`)),y(`.oxlintrc.json`,w(`test/.oxlintrc.json`)),y(`.oxfmtrc.json`,w(`test/.oxfmtrc.json`)),x(`vitest.config.mts`,w(`test/vitest.config.mts`)),S(`src/demo.test.ts`,T(`import { expect, test } from "vitest";
|
|
17
17
|
|
|
18
18
|
test("scaffolded block sanity check", () => {
|
|
19
19
|
expect(true).toBe(true);
|
|
20
20
|
});
|
|
21
|
-
`)),b(`package.json`,D(e=>Hr(e)),()=>{Ur()})})}var Gr=`block-tools software build`,Kr=`shx rm -f *.tgz && block-tools software build && pnpm pack && shx mv platforma-open*.tgz package.tgz`;function qr(){return{entrypoints:{main:{binary:{artifact:{type:`python`,registry:`platforma-open`,environment:`@platforma-open/milaboratories.runenv-python-3:3.12.10`,dependencies:{toolset:`pip`,requirements:`requirements.txt`},root:`./src`},cmd:[`python`,`{pkg}/main.py`]}}}}}function Jr(e){return{name:`${e.blockVars.facadeName}.software`,version:Y,type:`module`,description:`Block Software`,files:[`./dist/**/*`],scripts:{build:Gr,"do-pack":Kr,changeset:`changeset`,"version-packages":`changeset version`},"block-software":qr(),devDependencies:{"@platforma-open/milaboratories.runenv-python-3":`catalog:`,"@platforma-sdk/block-tools":`sdk:`}}}function Yr(){
|
|
21
|
+
`)),b(`package.json`,D(e=>Hr(e)),()=>{Ur()})})}var Gr=`block-tools software build`,Kr=`shx rm -f *.tgz && block-tools software build && pnpm pack && shx mv platforma-open*.tgz package.tgz`;function qr(){return{entrypoints:{main:{binary:{artifact:{type:`python`,registry:`platforma-open`,environment:`@platforma-open/milaboratories.runenv-python-3:3.12.10`,dependencies:{toolset:`pip`,requirements:`requirements.txt`},root:`./src`},cmd:[`python`,`{pkg}/main.py`]}}}}}function Jr(e){return{name:`${e.blockVars.facadeName}.software`,version:Y,type:`module`,description:`Block Software`,files:[`./dist/**/*`],scripts:{build:Gr,"do-pack":Kr,changeset:`changeset`,"version-packages":`changeset version`},"block-software":qr(),devDependencies:{"@platforma-open/milaboratories.runenv-python-3":`catalog:`,"@platforma-sdk/block-tools":`sdk:`}}}function Yr(){F(`private`),X(),P(`type`,`module`),P(`files`,[`./dist/**/*`]),I(`build`,Gr),I(`do-pack`,Kr),L(`prepublishOnly`),I(`changeset`,`changeset`),I(`version-packages`,`changeset version`),z(`@platforma-open/milaboratories.runenv-python-3`,`catalog:`),z(`@platforma-sdk/block-tools`,`sdk:`),B(`@platforma-sdk/package-builder`),W(`dependencies`),W(`devDependencies`),W(`peerDependencies`),W(`optionalDependencies`),U([...J])}var Xr=`import sys
|
|
22
22
|
|
|
23
23
|
print("Hello from Python, " + sys.argv[1] + "!")
|
|
24
24
|
`,Zr=`# No dependencies specified for this script
|
|
25
|
-
`;function Qr(){g(`software`,()=>{S(`src/main.py`,T(Xr)),S(`src/requirements.txt`,T(Zr)),b(`package.json`,D(e=>Jr(e)),()=>{Yr()})})}function $r(){g(`model`,()=>{C(`eslint.config.mjs`),C(`vite.config.mts`)}),g(`ui`,()=>{C(`eslint.config.mjs`),C(`vite.config.ts`),C(`tsconfig.app.json`),C(`tsconfig.node.json`)}),g(`test`,()=>{C(`eslint.config.mjs`)}),g(`root`,()=>{C(`.prettierrc`),b(`package.json`,D(()=>Cn()),()=>{
|
|
26
|
-
`)}`}async function
|
|
27
|
-
`)||` (none)`}`);if(!t.skipConfirmation){let e=(await import(`node:readline`)).createInterface({input:process.stdin,output:process.stdout}),r=await new Promise(n=>{e.question(`⚠️ This will overwrite the current global overview with snapshot '${t.snapshot}'.\nAre you sure you want to continue? (y/N): `,n)});if(e.close(),r.toLowerCase()!==`y`&&r.toLowerCase()!==`yes`){n.info(`Restore cancelled.`);return}}try{await i.restoreGlobalOverviewFromSnapshot(t.snapshot),n.info(`✅ Successfully restored global overview from snapshot '${t.snapshot}'`)}catch(e){throw Error(`Failed to restore from snapshot: ${String(e)}`)}}),n}function ui(e){let t=e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);if(t){let{src:e,destName:n}=t.groups;return{src:e,destName:n}}return{src:e,destName:n.default.basename(e)}}function di(e,n){return new t.Option(e,n).argParser((e,t)=>[...t??[],ui(e)]).default([])}var fi=[`registry`,`organization`,`package`,`version`];function pi(){let n=new t.Command(`upload-package-v1`).description(`Uploads V1 package and refreshes the registry`);return n.addOption(new t.Option(`-r, --registry <address|alias>`,`full address of the registry or alias from .pl.reg`).env(`PL_REGISTRY`)),n.addOption(new t.Option(`-o, --organization <organization>`,`target organisation`).env(`PL_PACKAGE_ORGANIZATION`)),n.addOption(new t.Option(`-p, --package <package>`,`target package`).env(`PL_PACKAGE_NAME`)),n.addOption(new t.Option(`-v, --version <version>`,`target version`).env(`PL_PACKAGE_VERSION`)),n.option(`-m, --meta <path>`,`json file containing meta information to associate with tha package`),n.addOption(di(`-f, --file <file>`,`package files`)),n.addOption(new t.Option(`--refresh`,`refresh repository after adding the package`).default(!0).env(`PL_REGISTRY_REFRESH`)),n.option(`--no-refresh`,`do not refresh repository after adding the package`),n.action(async t=>{let n=new o.ConsoleLoggerAdapter,i=e.p.parse({});for(let e of fi)t[e]&&(i[e]=t[e]);t.meta&&(t.meta.endsWith(`.json`)?i.meta=JSON.parse(await r.default.promises.readFile(t.meta,{encoding:`utf-8`})):t.meta.endsWith(`.yaml`)&&(i.meta=s.default.parse(await r.default.promises.readFile(t.meta,{encoding:`utf-8`}))));for(let e of t.file)i.files[e.destName]=e.src;let a=await e.n(i);n.info(s.default.stringify(a.conf));let c=a.createRegistry(n),l=a.fullPackageName,u=c.constructNewPackage(l);for(let[e,t]of Object.entries(a.conf.files)){n.info(`Uploading ${t} -> ${e} ...`);let i=await r.default.promises.readFile(t);await u.addFile(e,i)}n.info(`Uploading meta information...`),await u.writeMeta(a.conf.meta),await u.finish(),t.refresh&&await c.updateIfNeeded()}),n}function mi(e){let r=new t.Command(`check`).description(`Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.`);return r.argument(`[paths...]`,`block path(s); defaults to the current directory`),r.option(`--sdk-internal`,`block(s) live inside the SDK monorepo; skip root-scope rules`),r.action(async(t,r)=>{let i=new o.ConsoleLoggerAdapter,a=t.length>0?t:[`.`],s=n.default.join(e,`src`,`structure`,`templates`),c=!1;for(let e of a){let t=await ri({blockPath:e,isSdkInternal:!!r.sdkInternal,updateDepsOnly:!1,mode:`check`,templatesRoot:s,log:e=>i.info(e)});i.info(ii(e,t.changes)),t.changes.length>0&&(c=!0)}if(c)throw Error("Structure check failed: one or more blocks are out of date. Run `structure refresh`.")}),r}var $=[`python`],hi=class extends Error{constructor(e){super(`Missing required flag --${e} in --non-interactive mode. Supply every BlockVars flag, or drop --non-interactive to be prompted.`),this.name=`InitFlagError`}};async function gi(e,t,n,r){if(e!==void 0&&e!==``)return e;if(n)throw new hi(t);return r()}async function _i(e){let t=await gi(e.npmOrg,`npm-org`,e.nonInteractive,()=>(0,u.input)({message:`npm org (e.g. @platforma-open):`,default:`@platforma-open`})),n=await gi(e.orgScope,`org-scope`,e.nonInteractive,()=>(0,u.input)({message:`org scope (e.g. my-org):`})),r=await gi(e.shortName,`short-name`,e.nonInteractive,()=>(0,u.input)({message:`block short name (e.g. mixcr-clonotyping):`})),i;i=e.withSoftware===void 0?!e.nonInteractive&&await(0,u.confirm)({message:`Include a software module?`,default:!1}):e.withSoftware;let a;if(i){if(a=await gi(e.platform,`platform`,e.nonInteractive,()=>(0,u.select)({message:`Software platform:`,choices:$.map(e=>({name:e,value:e}))})),!$.includes(a))throw Error(`Unsupported --platform '${a}'. Only ${$.join(`, `)} ${$.length===1?`is`:`are`} supported at v1.`)}else if(e.platform)throw Error(`--platform was given but software is disabled (--no-software).`);return{facadeName:`${t}/${n}.${r}`,baseName:`${n}.${r}`,npmOrg:t,orgScope:n,shortName:r,softwarePlatform:a}}async function vi(e){let t=e.vars,n=an(t),r=new ce(e.blockPath),i=new le(e.templatesRoot),a=on({blockVars:t,modules:n,isSdkInternal:!1,version:3,dryRun:!1}),o=Z.filter(zn),s,c;try{s=await Bn(o),c=await Hn(qn)}catch(e){throw Error(`init requires network access to resolve SDK catalog versions from npm, but the registry lookup failed: ${e instanceof Error?e.message:String(e)}`)}return Yt(ti,r,a,{templates:i,initMode:!0,registryLookup:s,derivedPinLookup:c}),e.log(`Initialised block '${t.facadeName}'${t.softwarePlatform?` (software: ${t.softwarePlatform})`:` (no software)`} at ${e.blockPath}`),t}function yi(e){let r=new t.Command(`init`).description(`Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.`);return r.argument(`[path]`,`target directory (default: <short-name> under the current directory)`),r.option(`--npm-org <org>`,`npm org, e.g. @platforma-open`),r.option(`--org-scope <scope>`,`org scope, e.g. my-org`),r.option(`--short-name <name>`,`block short name, e.g. mixcr-clonotyping`),r.option(`--with-software`,`include a software module`),r.option(`--no-software`,`omit the software module`),r.addOption(new t.Option(`--platform <platform>`,`software platform (single-valued)`).choices([...$])),r.option(`--non-interactive`,`error on any missing flag instead of prompting`),r.action(async(t,r)=>{let i=new o.ConsoleLoggerAdapter,a=r.withSoftware===!0,s=r.software===!1;if(a&&s)throw Error(`--with-software and --no-software are mutually exclusive.`);let c=a?!0:!s&&void 0,l=await _i({npmOrg:r.npmOrg,orgScope:r.orgScope,shortName:r.shortName,withSoftware:c,platform:r.platform,nonInteractive:r.nonInteractive});await vi({vars:l,blockPath:t?n.default.resolve(t):n.default.resolve(process.cwd(),l.shortName),templatesRoot:n.default.join(e,`src`,`structure`,`templates`),log:e=>i.info(e)})}),r}var bi=[`dev`,`release`],xi=[`docker`,`binary`,`all`,`none`],Si=[`local`,`remote`];function Ci(e){if(e.usePublished){if(e.variant===`docker`||e.variant===`all`)throw a.util.CLIError(`--use-published is binary-only and cannot be combined with --variant ${e.variant}`);return{kind:`binary-existing`}}return e.variant===`none`?{kind:`no-software`}:e.location===void 0?{kind:`bare`}:{kind:`target`,channel:e.channel??`release`,variant:e.variant??`all`,location:e.location}}var wi=`public.ecr.aws`,Ti=`us-east-1`;function Ei(e){if(process.env.AWS_ACCESS_KEY_ID||process.env.AWS_PROFILE)return;let t=process.env.PL_AWS_PROFILE??a.defaults.AWS_DEV_PROFILE;process.env.AWS_PROFILE=t,e?.debug(`Using AWS profile '${t}' for dev push credentials`)}function Di(e){return new URL(`https://${e}`).hostname}function Oi(){return` aws sso login --profile ${process.env.AWS_PROFILE??process.env.PL_AWS_PROFILE??a.defaults.AWS_DEV_PROFILE}`}async function ki(e,t){let n=Di(e);if(n!==wi)throw a.util.CLIError(`automatic docker login is only supported for '${wi}', not '${n}'.\nLog in manually, or drop the ecr:// scheme from the push target to opt out.`);t?.info(`Logging in to ECR registry '${n}'...`);let r,i;try{let e=(await new f.ECRPUBLICClient({region:Ti}).send(new f.GetAuthorizationTokenCommand({}))).authorizationData?.authorizationToken;if(!e)throw Error(`empty authorization token`);let t=Buffer.from(e,`base64`).toString(`utf8`),n=t.indexOf(`:`);if(n<0)throw Error(`malformed authorization token (no ':' separator)`);r=t.slice(0,n),i=t.slice(n+1)}catch(e){throw a.util.CLIError(`failed to obtain an ECR login token for '${n}': ${e instanceof Error?e.message:String(e)}\nYour AWS/SSO session is likely expired or absent — log in and retry:\n`+Oi())}let o=(0,d.spawnSync)(`docker`,[`login`,`--username`,r,`--password-stdin`,n],{input:i,stdio:[`pipe`,`inherit`,`inherit`],env:{...process.env,HOME:process.env.HOME||l.homedir()}});if(o.error||o.status!==0)throw a.util.CLIError(`'docker login ${n}' failed`)}async function Ai(e){let{core:t,scenario:n,options:r={},logger:i}=e,o=r.ids;t.buildMode=Mi(n),ji(n)||t.assertDockerCoverage();let s=()=>t.buildSoftwareArchives({ids:o,forceBuild:!!r.force,contentRoot:r.contentRoot,skipIfEmpty:!o,condaBuild:r.condaBuild});switch(n.kind){case`binary-existing`:t.writePublishedArtifactInfo({ids:o});break;case`no-software`:break;case`bare`:r.buildDocker&&t.buildDockerImages({ids:o,registry:r.dockerRegistry,strictPlatformMatching:a.envs.isCI()}),await s(),r.pushDocker&&t.publishDockerImages({ids:o,pushTo:r.dockerPushTo,strictPlatformMatching:a.envs.isCI()});break;case`target`:{let{channel:e,variant:c,location:l}=n,u=c!==`binary`,d=c!==`docker`,f=l===`remote`,p=Fi(e,r);u&&t.buildDockerImages({ids:o,registry:p.pull,strictPlatformMatching:a.envs.isCI()}),d&&await s(),f&&e===`dev`&&(u||d)&&Ei(i),u&&f&&(p.autoLogin&&p.push&&await ki(p.push,i),t.publishDockerImages({ids:o,pushTo:p.push,strictPlatformMatching:a.envs.isCI()})),d&&f&&await t.publishPackages({ids:o,storageURL:r.storageUrl});break}default:a.util.assertNever(n)}t.buildSwJsonFiles({packageIds:o,noSoftware:n.kind===`no-software`,skipDockerCoverage:ji(n)})}function ji(e){return e.kind===`no-software`||e.kind===`binary-existing`}function Mi(e){return e.kind!==`target`||e.channel===`release`?`release`:e.variant!==`docker`&&e.location===`remote`?`dev-remote`:`dev-local`}function Ni(e){if(!e.includes(`://`))return e;let t=new URL(e);return t.host+t.pathname}function Pi(e){return{registry:Ni(e),autoLogin:e.startsWith(`ecr://`)}}function Fi(e,t){let n=e===`dev`,r=process.env[n?a.envs.PL_DEV_DOCKER_PUSH_URL:a.envs.PL_RELEASE_DOCKER_PUSH_URL],i=process.env[n?a.envs.PL_DEV_DOCKER_PULL_URL:a.envs.PL_RELEASE_DOCKER_PULL_URL],o=t.dockerPushTo??r??(n?a.defaults.DEV_DOCKER_PUSH_TARGET:void 0),s=o?Pi(o):{registry:void 0,autoLogin:!1},c=t.dockerRegistry??i??(n?o:a.defaults.DOCKER_REGISTRY);return{pull:c?Ni(c):void 0,push:s.registry,autoLogin:s.autoLogin}}var Ii=`PL_BUILD_CHANNEL`,Li=`PL_BUILD_VARIANT`,Ri=`PL_BUILD_LOCATION`,zi=`PL_BUILD_USE_PUBLISHED`;a.envs.PL_DOCKER_REGISTRY_PUSH_TO,a.envs.PL_DEV_DOCKER_PUSH_URL,a.envs.PL_DEV_DOCKER_PULL_URL,a.envs.PL_DEV_BINARY_UPLOAD_URL,a.envs.PL_RELEASE_DOCKER_PUSH_URL,a.envs.PL_RELEASE_DOCKER_PULL_URL,a.envs.PL_RELEASE_BINARY_UPLOAD_URL;function Bi(){let e=new t.Command(`build`).description(`Build a software module for a target and write its .sw.json descriptor (build + push in one pass)`);return e.addOption(new t.Option(`--channel <channel>`,`registry channel to build for`).choices([...bi]).env(Ii)),e.addOption(new t.Option(`--variant <variant>`,`artifact kind to build (default: all declared)`).choices([...xi]).env(Li)),e.addOption(new t.Option(`--location <location>`,`where the artifact lands (local = no push)`).choices([...Si]).env(Ri)),e.addOption(new t.Option(`--use-published`,`do not build or push; emit a descriptor pointing at the already-published release artifact`).env(zi)),e.addOption(new t.Option(`--log-level <level>`,`logging level`).choices([`error`,`warn`,`info`,`debug`]).default(`info`)),e.addOption(new t.Option(`--package-root <path>`,`path to directory with package.json file`)),e.addOption(new t.Option(`--force`,`force action, ignoring automatic safety checks`).default(!1)),e.addOption(new t.Option(`--version <value>`,`override package version (ignore package.json)`)),e.addOption(new t.Option(`--platform <os-arch>`,`{os}-{arch} pair; no effect on cross-platform packages`).choices([...a.util.AllPlatforms]).env(a.envs.PL_PKG_OS)),e.addOption(new t.Option(`--all-platforms`,`build for all supported platforms`).default(!1)),e.addOption(new t.Option(`--full-dir-hash`,`hash file contents (not metadata) for the dev content hash`).env(a.envs.PL_PKG_FULL_HASH).default(!1)),e.addOption(new t.Option(`--package-id <id...>`,`act only on selected packages`)),e.addOption(new t.Option(`--content-root <path>`,`override software content root`).env(a.envs.PL_PKG_CONTENT_ROOT)),e.addOption(new t.Option(`--storage-url <url>`,`override binary upload registry URL`).env(a.envs.PL_PKG_STORAGE_URL)),e.addOption(new t.Option(`--docker-registry <registry>`,`docker pull registry embedded in the descriptor`).env(a.envs.PL_DOCKER_REGISTRY)),e.addOption(new t.Option(`--docker-push-to <registry>`,`alternative registry for docker push`).env(a.envs.PL_DOCKER_REGISTRY_PUSH_TO)),e.addOption(new t.Option(`--docker-build`,`build docker images`).env(a.envs.PL_DOCKER_BUILD).default(!1)),e.addOption(new t.Option(`--docker-no-build`,`do not build docker images`).env(a.envs.PL_DOCKER_NO_BUILD).default(!1)),e.addOption(new t.Option(`--docker-autopush`,`push docker images after build`).env(a.envs.PL_DOCKER_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--docker-no-autopush`,`do not push docker images`).env(a.envs.PL_DOCKER_NO_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--conda-build`,`build conda environment before packing`).env(a.envs.PL_CONDA_BUILD).default(!1)),e.addOption(new t.Option(`--conda-no-build`,`do not build conda environment`).env(a.envs.PL_CONDA_NO_BUILD).default(!1)),e.action(async e=>{let t=a.util.createLogger(e.logLevel);try{let n=Ci({channel:e.channel,variant:e.variant,location:e.location,usePublished:!!e.usePublished}),r=(0,a.createBuilder)(t,{packageRoot:e.packageRoot});r.version=e.version,r.targetPlatform=e.platform,r.allPlatforms=!!e.allPlatforms,r.fullDirHash=!!e.fullDirHash;let i=a.util.shouldDoAction({default:a.envs.isCI(),enable:e.dockerBuild,disable:e.dockerNoBuild}),o=i&&a.util.shouldDoAction({default:a.envs.isCI()&&!r.isPrivate,enable:e.dockerAutopush,disable:e.dockerNoAutopush});n.kind===`bare`&&(0,a.assertDockerPushIntent)({buildDocker:i,pushDocker:o,pushDisabledExplicitly:!!e.dockerNoAutopush,dockerPackageCount:r.selectedDockerPackages(e.packageId).length}),await Ai({core:r,scenario:n,logger:t,options:{ids:e.packageId,force:e.force,contentRoot:e.contentRoot,storageUrl:e.storageUrl,dockerRegistry:e.dockerRegistry,dockerPushTo:e.dockerPushTo,buildDocker:i,pushDocker:o,condaBuild:a.util.shouldDoAction({default:!0,enable:e.condaBuild,disable:e.condaNoBuild})}})}catch(e){throw t.debug(e),e instanceof Error&&t.debug(e.stack),e}}),e}function Vi(){let e=new t.Command(`software`).description(`Build and publish a block's software modules`);return e.addCommand(Bi()),e}function Hi(e=process.cwd()){let n=new t.Command;n.name(`block-tools`).description(`Utility to manipulate Platforma Blocks and Block Registry`),n.addCommand(p()),n.addCommand(te()),n.addCommand(ne()),n.addCommand(re()),n.addCommand(ae()),n.addCommand(oe()),n.addCommand(se()),n.addCommand(si(e)),n.addCommand(ci()),n.addCommand(li()),n.addCommand(pi()),n.addCommand(Vi());let r=new t.Command(`structure`).description(`Manage block scaffolding against the canonical structure (check / init / refresh)`);return r.addCommand(mi(e)),r.addCommand(yi(e)),r.addCommand(oi(e)),n.addCommand(r),n}async function Ui(e,t){await Hi(t).parseAsync(e)}exports.buildProgram=Hi,exports.run=Ui;
|
|
25
|
+
`;function Qr(){g(`software`,()=>{S(`src/main.py`,T(Xr)),S(`src/requirements.txt`,T(Zr)),b(`package.json`,D(e=>Jr(e)),()=>{Yr()})})}function $r(){g(`model`,()=>{C(`eslint.config.mjs`),C(`vite.config.mts`)}),g(`ui`,()=>{C(`eslint.config.mjs`),C(`vite.config.ts`),C(`tsconfig.app.json`),C(`tsconfig.node.json`)}),g(`test`,()=>{C(`eslint.config.mjs`)}),g(`root`,()=>{C(`.prettierrc`),b(`package.json`,D(()=>Cn()),()=>{L(`pretty`),B(`@platforma-sdk/blocks-deps-updater`)})})}function ei(){je(()=>{g(`root`,()=>{_(({ctx:e})=>!e.isSdkInternal,()=>{b(`pnpm-workspace.yaml`,D(e=>Xn(e)),e=>{for(let e of Z)St(e);for(let e of qn)Ct(e.entry,{of:e.of,ofVersion:e.ofVersion});e.modules.some(e=>e.scope===`software`)&&xt(Jn,Yn)})})})})}var ti=we(()=>{fr(),mr(),Dr(),jr(),Fr(),Rr(),Vr(),Wr(),Qr(),$r(),ei()});async function ni(){return Bn(Z.filter(zn))}async function ri(e){let t=n.default.resolve(e.blockPath),r=e.mode===`check`,i=new ce(t),a=new le(e.templatesRoot),o=Yt(ti,i,pn({fs:i,isSdkInternal:e.isSdkInternal,updateDepsOnly:e.updateDepsOnly,dryRun:r}),{templates:a,registryLookup:e.updateDepsOnly?await ni():void 0,derivedPinLookup:e.updateDepsOnly?await Hn(qn):void 0,rediscover:()=>pn({fs:i,isSdkInternal:e.isSdkInternal,updateDepsOnly:!1,dryRun:!0})});return{blockPath:e.blockPath,changes:o.changes}}function ii(e){let t=e.flatMap(e=>/[*?[]/.test(e)?(0,r.globSync)(e).filter(e=>(0,r.statSync)(e,{throwIfNoEntry:!1})?.isDirectory()===!0).map(e=>e.split(n.default.sep).join(`/`)).sort():[e]);return[...new Set(t)]}function ai(e,t){if(t.length===0)return` ${e}: up to date (0 changes)`;let n=t.map(e=>` ${e.action.padEnd(6)} ${e.primitive.padEnd(8)} ${e.path} [${e.scope}]`);return` ${e}: ${t.length} change(s)\n${n.join(`
|
|
26
|
+
`)}`}async function oi(e){for(let t of e.paths){let n=await ri({blockPath:t,isSdkInternal:e.isSdkInternal,updateDepsOnly:e.updateDepsOnly,mode:`refresh`,templatesRoot:e.templatesRoot,log:t=>e.logger.info(t)});e.logger.info(ai(t,n.changes))}}function si(e){let r=new t.Command(`refresh`).description(`Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).`);return r.argument(`[paths...]`,`block path(s); defaults to the current directory`),r.option(`--sdk-internal`,`block(s) live inside the SDK monorepo; skip root-scope rules`),r.option(`--update-deps-only`,"fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh."),r.action(async(t,r)=>{let i=t.length>0?ii(t):[`.`],a=n.default.join(e,`src`,`structure`,`templates`);await oi({paths:i,isSdkInternal:!!r.sdkInternal,updateDepsOnly:!!r.updateDepsOnly,templatesRoot:a,logger:new o.ConsoleLoggerAdapter})}),r}function ci(e){let r=new t.Command(`update-deps`).description("[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.");return r.action(async()=>{let t=new o.ConsoleLoggerAdapter;t.warn("`block-tools update-deps` is deprecated and will be removed in a future release. Use `block-tools structure refresh --update-deps-only` instead. Delegating now."),await oi({paths:[`.`],isSdkInternal:!1,updateDepsOnly:!0,templatesRoot:n.default.join(e,`src`,`structure`,`templates`),logger:t})}),r}function li(){let n=new t.Command(`list-overview-snapshots`).description(`List all available global overview snapshots in the registry`);return n.addOption(new t.Option(`-r, --registry <address>`,`full address of the registry`).env(`PL_REGISTRY`).makeOptionMandatory()),n.option(`--json`,`output in JSON format`,!1),n.action(async t=>{let n=new o.ConsoleLoggerAdapter,r=e._(t.registry),i=await new e.w(r,n).listGlobalOverviewSnapshots();if(t.json)n.info(JSON.stringify(i,null,2));else if(i.length===0)n.info(`No snapshots found.`);else{n.info(`Found ${i.length} snapshot(s):\n`);for(let e of i)n.info(` ${e.timestamp}`),n.info(` Path: ${e.path}`),n.info(``)}}),n}function ui(){let n=new t.Command(`restore-overview-from-snapshot`).description(`Restore global overview from a snapshot`);return n.addOption(new t.Option(`-r, --registry <address>`,`full address of the registry`).env(`PL_REGISTRY`).makeOptionMandatory()),n.requiredOption(`-s, --snapshot <timestamp>`,`snapshot timestamp ID to restore from`),n.option(`--skip-confirmation`,`skip confirmation prompt (use with caution)`,!1),n.action(async t=>{let n=new o.ConsoleLoggerAdapter,r=e._(t.registry),i=new e.w(r,n),a=await i.listGlobalOverviewSnapshots();if(!a.find(e=>e.timestamp===t.snapshot))throw Error(`Snapshot '${t.snapshot}' not found. Available snapshots:\n${a.map(e=>` - ${e.timestamp}`).join(`
|
|
27
|
+
`)||` (none)`}`);if(!t.skipConfirmation){let e=(await import(`node:readline`)).createInterface({input:process.stdin,output:process.stdout}),r=await new Promise(n=>{e.question(`⚠️ This will overwrite the current global overview with snapshot '${t.snapshot}'.\nAre you sure you want to continue? (y/N): `,n)});if(e.close(),r.toLowerCase()!==`y`&&r.toLowerCase()!==`yes`){n.info(`Restore cancelled.`);return}}try{await i.restoreGlobalOverviewFromSnapshot(t.snapshot),n.info(`✅ Successfully restored global overview from snapshot '${t.snapshot}'`)}catch(e){throw Error(`Failed to restore from snapshot: ${String(e)}`)}}),n}function di(e){let t=e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);if(t){let{src:e,destName:n}=t.groups;return{src:e,destName:n}}return{src:e,destName:n.default.basename(e)}}function fi(e,n){return new t.Option(e,n).argParser((e,t)=>[...t??[],di(e)]).default([])}var pi=[`registry`,`organization`,`package`,`version`];function mi(){let n=new t.Command(`upload-package-v1`).description(`Uploads V1 package and refreshes the registry`);return n.addOption(new t.Option(`-r, --registry <address|alias>`,`full address of the registry or alias from .pl.reg`).env(`PL_REGISTRY`)),n.addOption(new t.Option(`-o, --organization <organization>`,`target organisation`).env(`PL_PACKAGE_ORGANIZATION`)),n.addOption(new t.Option(`-p, --package <package>`,`target package`).env(`PL_PACKAGE_NAME`)),n.addOption(new t.Option(`-v, --version <version>`,`target version`).env(`PL_PACKAGE_VERSION`)),n.option(`-m, --meta <path>`,`json file containing meta information to associate with tha package`),n.addOption(fi(`-f, --file <file>`,`package files`)),n.addOption(new t.Option(`--refresh`,`refresh repository after adding the package`).default(!0).env(`PL_REGISTRY_REFRESH`)),n.option(`--no-refresh`,`do not refresh repository after adding the package`),n.action(async t=>{let n=new o.ConsoleLoggerAdapter,i=e.p.parse({});for(let e of pi)t[e]&&(i[e]=t[e]);t.meta&&(t.meta.endsWith(`.json`)?i.meta=JSON.parse(await r.default.promises.readFile(t.meta,{encoding:`utf-8`})):t.meta.endsWith(`.yaml`)&&(i.meta=s.default.parse(await r.default.promises.readFile(t.meta,{encoding:`utf-8`}))));for(let e of t.file)i.files[e.destName]=e.src;let a=await e.n(i);n.info(s.default.stringify(a.conf));let c=a.createRegistry(n),l=a.fullPackageName,u=c.constructNewPackage(l);for(let[e,t]of Object.entries(a.conf.files)){n.info(`Uploading ${t} -> ${e} ...`);let i=await r.default.promises.readFile(t);await u.addFile(e,i)}n.info(`Uploading meta information...`),await u.writeMeta(a.conf.meta),await u.finish(),t.refresh&&await c.updateIfNeeded()}),n}function hi(e){let r=new t.Command(`check`).description(`Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.`);return r.argument(`[paths...]`,`block path(s); defaults to the current directory`),r.option(`--sdk-internal`,`block(s) live inside the SDK monorepo; skip root-scope rules`),r.action(async(t,r)=>{let i=new o.ConsoleLoggerAdapter,a=t.length>0?ii(t):[`.`],s=n.default.join(e,`src`,`structure`,`templates`),c=!1;for(let e of a){let t=await ri({blockPath:e,isSdkInternal:!!r.sdkInternal,updateDepsOnly:!1,mode:`check`,templatesRoot:s,log:e=>i.info(e)});i.info(ai(e,t.changes)),t.changes.length>0&&(c=!0)}if(c)throw Error("Structure check failed: one or more blocks are out of date. Run `structure refresh`.")}),r}var $=[`python`],gi=class extends Error{constructor(e){super(`Missing required flag --${e} in --non-interactive mode. Supply every BlockVars flag, or drop --non-interactive to be prompted.`),this.name=`InitFlagError`}};async function _i(e,t,n,r){if(e!==void 0&&e!==``)return e;if(n)throw new gi(t);return r()}async function vi(e){let t=await _i(e.npmOrg,`npm-org`,e.nonInteractive,()=>(0,u.input)({message:`npm org (e.g. @platforma-open):`,default:`@platforma-open`})),n=await _i(e.orgScope,`org-scope`,e.nonInteractive,()=>(0,u.input)({message:`org scope (e.g. my-org):`})),r=await _i(e.shortName,`short-name`,e.nonInteractive,()=>(0,u.input)({message:`block short name (e.g. mixcr-clonotyping):`})),i;i=e.withSoftware===void 0?!e.nonInteractive&&await(0,u.confirm)({message:`Include a software module?`,default:!1}):e.withSoftware;let a;if(i){if(a=await _i(e.platform,`platform`,e.nonInteractive,()=>(0,u.select)({message:`Software platform:`,choices:$.map(e=>({name:e,value:e}))})),!$.includes(a))throw Error(`Unsupported --platform '${a}'. Only ${$.join(`, `)} ${$.length===1?`is`:`are`} supported at v1.`)}else if(e.platform)throw Error(`--platform was given but software is disabled (--no-software).`);return{facadeName:`${t}/${n}.${r}`,baseName:`${n}.${r}`,npmOrg:t,orgScope:n,shortName:r,softwarePlatform:a}}async function yi(e){let t=e.vars,n=an(t),r=new ce(e.blockPath),i=new le(e.templatesRoot),a=on({blockVars:t,modules:n,isSdkInternal:!1,version:3,dryRun:!1}),o=Z.filter(zn),s,c;try{s=await Bn(o),c=await Hn(qn)}catch(e){throw Error(`init requires network access to resolve SDK catalog versions from npm, but the registry lookup failed: ${e instanceof Error?e.message:String(e)}`)}return Yt(ti,r,a,{templates:i,initMode:!0,registryLookup:s,derivedPinLookup:c}),e.log(`Initialised block '${t.facadeName}'${t.softwarePlatform?` (software: ${t.softwarePlatform})`:` (no software)`} at ${e.blockPath}`),t}function bi(e){let r=new t.Command(`init`).description(`Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.`);return r.argument(`[path]`,`target directory (default: <short-name> under the current directory)`),r.option(`--npm-org <org>`,`npm org, e.g. @platforma-open`),r.option(`--org-scope <scope>`,`org scope, e.g. my-org`),r.option(`--short-name <name>`,`block short name, e.g. mixcr-clonotyping`),r.option(`--with-software`,`include a software module`),r.option(`--no-software`,`omit the software module`),r.addOption(new t.Option(`--platform <platform>`,`software platform (single-valued)`).choices([...$])),r.option(`--non-interactive`,`error on any missing flag instead of prompting`),r.action(async(t,r)=>{let i=new o.ConsoleLoggerAdapter,a=r.withSoftware===!0,s=r.software===!1;if(a&&s)throw Error(`--with-software and --no-software are mutually exclusive.`);let c=a?!0:!s&&void 0,l=await vi({npmOrg:r.npmOrg,orgScope:r.orgScope,shortName:r.shortName,withSoftware:c,platform:r.platform,nonInteractive:r.nonInteractive});await yi({vars:l,blockPath:t?n.default.resolve(t):n.default.resolve(process.cwd(),l.shortName),templatesRoot:n.default.join(e,`src`,`structure`,`templates`),log:e=>i.info(e)})}),r}var xi=[`dev`,`release`],Si=[`docker`,`binary`,`all`,`none`],Ci=[`local`,`remote`];function wi(e){if(e.usePublished){if(e.variant===`docker`||e.variant===`all`)throw a.util.CLIError(`--use-published is binary-only and cannot be combined with --variant ${e.variant}`);return{kind:`binary-existing`}}return e.variant===`none`?{kind:`no-software`}:e.location===void 0?{kind:`bare`}:{kind:`target`,channel:e.channel??`release`,variant:e.variant??`all`,location:e.location}}var Ti=`public.ecr.aws`,Ei=`us-east-1`;function Di(e){if(process.env.AWS_ACCESS_KEY_ID||process.env.AWS_PROFILE)return;let t=process.env.PL_AWS_PROFILE??a.defaults.AWS_DEV_PROFILE;process.env.AWS_PROFILE=t,e?.debug(`Using AWS profile '${t}' for dev push credentials`)}function Oi(e){return new URL(`https://${e}`).hostname}function ki(){return` aws sso login --profile ${process.env.AWS_PROFILE??process.env.PL_AWS_PROFILE??a.defaults.AWS_DEV_PROFILE}`}async function Ai(e,t){let n=Oi(e);if(n!==Ti)throw a.util.CLIError(`automatic docker login is only supported for '${Ti}', not '${n}'.\nLog in manually, or drop the ecr:// scheme from the push target to opt out.`);t?.info(`Logging in to ECR registry '${n}'...`);let r,i;try{let e=(await new f.ECRPUBLICClient({region:Ei}).send(new f.GetAuthorizationTokenCommand({}))).authorizationData?.authorizationToken;if(!e)throw Error(`empty authorization token`);let t=Buffer.from(e,`base64`).toString(`utf8`),n=t.indexOf(`:`);if(n<0)throw Error(`malformed authorization token (no ':' separator)`);r=t.slice(0,n),i=t.slice(n+1)}catch(e){throw a.util.CLIError(`failed to obtain an ECR login token for '${n}': ${e instanceof Error?e.message:String(e)}\nYour AWS/SSO session is likely expired or absent — log in and retry:\n`+ki())}let o=(0,d.spawnSync)(`docker`,[`login`,`--username`,r,`--password-stdin`,n],{input:i,stdio:[`pipe`,`inherit`,`inherit`],env:{...process.env,HOME:process.env.HOME||l.homedir()}});if(o.error||o.status!==0)throw a.util.CLIError(`'docker login ${n}' failed`)}async function ji(e){let{core:t,scenario:n,options:r={},logger:i}=e,o=r.ids;t.buildMode=Ni(n),Mi(n)||t.assertDockerCoverage();let s=()=>t.buildSoftwareArchives({ids:o,forceBuild:!!r.force,contentRoot:r.contentRoot,skipIfEmpty:!o,condaBuild:r.condaBuild});switch(n.kind){case`binary-existing`:t.writePublishedArtifactInfo({ids:o});break;case`no-software`:break;case`bare`:r.buildDocker&&t.buildDockerImages({ids:o,registry:r.dockerRegistry,strictPlatformMatching:a.envs.isCI()}),await s(),r.pushDocker&&t.publishDockerImages({ids:o,pushTo:r.dockerPushTo,strictPlatformMatching:a.envs.isCI()});break;case`target`:{let{channel:e,variant:c,location:l}=n,u=c!==`binary`,d=c!==`docker`,f=l===`remote`,p=Ii(e,r);u&&t.buildDockerImages({ids:o,registry:p.pull,strictPlatformMatching:a.envs.isCI()}),d&&await s(),f&&e===`dev`&&(u||d)&&Di(i),u&&f&&(p.autoLogin&&p.push&&await Ai(p.push,i),t.publishDockerImages({ids:o,pushTo:p.push,strictPlatformMatching:a.envs.isCI()})),d&&f&&await t.publishPackages({ids:o,storageURL:r.storageUrl});break}default:a.util.assertNever(n)}t.buildSwJsonFiles({packageIds:o,noSoftware:n.kind===`no-software`,skipDockerCoverage:Mi(n)})}function Mi(e){return e.kind===`no-software`||e.kind===`binary-existing`}function Ni(e){return e.kind!==`target`||e.channel===`release`?`release`:e.variant!==`docker`&&e.location===`remote`?`dev-remote`:`dev-local`}function Pi(e){if(!e.includes(`://`))return e;let t=new URL(e);return t.host+t.pathname}function Fi(e){return{registry:Pi(e),autoLogin:e.startsWith(`ecr://`)}}function Ii(e,t){let n=e===`dev`,r=process.env[n?a.envs.PL_DEV_DOCKER_PUSH_URL:a.envs.PL_RELEASE_DOCKER_PUSH_URL],i=process.env[n?a.envs.PL_DEV_DOCKER_PULL_URL:a.envs.PL_RELEASE_DOCKER_PULL_URL],o=t.dockerPushTo??r??(n?a.defaults.DEV_DOCKER_PUSH_TARGET:void 0),s=o?Fi(o):{registry:void 0,autoLogin:!1},c=t.dockerRegistry??i??(n?o:a.defaults.DOCKER_REGISTRY);return{pull:c?Pi(c):void 0,push:s.registry,autoLogin:s.autoLogin}}var Li=`PL_BUILD_CHANNEL`,Ri=`PL_BUILD_VARIANT`,zi=`PL_BUILD_LOCATION`,Bi=`PL_BUILD_USE_PUBLISHED`;a.envs.PL_DOCKER_REGISTRY_PUSH_TO,a.envs.PL_DEV_DOCKER_PUSH_URL,a.envs.PL_DEV_DOCKER_PULL_URL,a.envs.PL_DEV_BINARY_UPLOAD_URL,a.envs.PL_RELEASE_DOCKER_PUSH_URL,a.envs.PL_RELEASE_DOCKER_PULL_URL,a.envs.PL_RELEASE_BINARY_UPLOAD_URL;function Vi(){let e=new t.Command(`build`).description(`Build a software module for a target and write its .sw.json descriptor (build + push in one pass)`);return e.addOption(new t.Option(`--channel <channel>`,`registry channel to build for`).choices([...xi]).env(Li)),e.addOption(new t.Option(`--variant <variant>`,`artifact kind to build (default: all declared)`).choices([...Si]).env(Ri)),e.addOption(new t.Option(`--location <location>`,`where the artifact lands (local = no push)`).choices([...Ci]).env(zi)),e.addOption(new t.Option(`--use-published`,`do not build or push; emit a descriptor pointing at the already-published release artifact`).env(Bi)),e.addOption(new t.Option(`--log-level <level>`,`logging level`).choices([`error`,`warn`,`info`,`debug`]).default(`info`)),e.addOption(new t.Option(`--package-root <path>`,`path to directory with package.json file`)),e.addOption(new t.Option(`--force`,`force action, ignoring automatic safety checks`).default(!1)),e.addOption(new t.Option(`--version <value>`,`override package version (ignore package.json)`)),e.addOption(new t.Option(`--platform <os-arch>`,`{os}-{arch} pair; no effect on cross-platform packages`).choices([...a.util.AllPlatforms]).env(a.envs.PL_PKG_OS)),e.addOption(new t.Option(`--all-platforms`,`build for all supported platforms`).default(!1)),e.addOption(new t.Option(`--full-dir-hash`,`hash file contents (not metadata) for the dev content hash`).env(a.envs.PL_PKG_FULL_HASH).default(!1)),e.addOption(new t.Option(`--package-id <id...>`,`act only on selected packages`)),e.addOption(new t.Option(`--content-root <path>`,`override software content root`).env(a.envs.PL_PKG_CONTENT_ROOT)),e.addOption(new t.Option(`--storage-url <url>`,`override binary upload registry URL`).env(a.envs.PL_PKG_STORAGE_URL)),e.addOption(new t.Option(`--docker-registry <registry>`,`docker pull registry embedded in the descriptor`).env(a.envs.PL_DOCKER_REGISTRY)),e.addOption(new t.Option(`--docker-push-to <registry>`,`alternative registry for docker push`).env(a.envs.PL_DOCKER_REGISTRY_PUSH_TO)),e.addOption(new t.Option(`--docker-build`,`build docker images`).env(a.envs.PL_DOCKER_BUILD).default(!1)),e.addOption(new t.Option(`--docker-no-build`,`do not build docker images`).env(a.envs.PL_DOCKER_NO_BUILD).default(!1)),e.addOption(new t.Option(`--docker-autopush`,`push docker images after build`).env(a.envs.PL_DOCKER_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--docker-no-autopush`,`do not push docker images`).env(a.envs.PL_DOCKER_NO_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--conda-build`,`build conda environment before packing`).env(a.envs.PL_CONDA_BUILD).default(!1)),e.addOption(new t.Option(`--conda-no-build`,`do not build conda environment`).env(a.envs.PL_CONDA_NO_BUILD).default(!1)),e.action(async e=>{let t=a.util.createLogger(e.logLevel);try{let n=wi({channel:e.channel,variant:e.variant,location:e.location,usePublished:!!e.usePublished}),r=(0,a.createBuilder)(t,{packageRoot:e.packageRoot});r.version=e.version,r.targetPlatform=e.platform,r.allPlatforms=!!e.allPlatforms,r.fullDirHash=!!e.fullDirHash;let i=a.util.shouldDoAction({default:a.envs.isCI(),enable:e.dockerBuild,disable:e.dockerNoBuild}),o=i&&a.util.shouldDoAction({default:a.envs.isCI()&&!r.isPrivate,enable:e.dockerAutopush,disable:e.dockerNoAutopush});n.kind===`bare`&&(0,a.assertDockerPushIntent)({buildDocker:i,pushDocker:o,pushDisabledExplicitly:!!e.dockerNoAutopush,dockerPackageCount:r.selectedDockerPackages(e.packageId).length}),await ji({core:r,scenario:n,logger:t,options:{ids:e.packageId,force:e.force,contentRoot:e.contentRoot,storageUrl:e.storageUrl,dockerRegistry:e.dockerRegistry,dockerPushTo:e.dockerPushTo,buildDocker:i,pushDocker:o,condaBuild:a.util.shouldDoAction({default:!0,enable:e.condaBuild,disable:e.condaNoBuild})}})}catch(e){throw t.debug(e),e instanceof Error&&t.debug(e.stack),e}}),e}function Hi(){let e=new t.Command(`software`).description(`Build and publish a block's software modules`);return e.addCommand(Vi()),e}function Ui(e=process.cwd()){let n=new t.Command;n.name(`block-tools`).description(`Utility to manipulate Platforma Blocks and Block Registry`),n.addCommand(p()),n.addCommand(te()),n.addCommand(ne()),n.addCommand(re()),n.addCommand(ae()),n.addCommand(oe()),n.addCommand(se()),n.addCommand(ci(e)),n.addCommand(li()),n.addCommand(ui()),n.addCommand(mi()),n.addCommand(Hi());let r=new t.Command(`structure`).description(`Manage block scaffolding against the canonical structure (check / init / refresh)`);return r.addCommand(hi(e)),r.addCommand(bi(e)),r.addCommand(si(e)),n.addCommand(r),n}async function Wi(e,t){await Ui(t).parseAsync(e)}exports.buildProgram=Ui,exports.run=Wi;
|
|
28
28
|
//# sourceMappingURL=cli.js.map
|