@platforma-sdk/block-tools 2.12.3 → 2.12.5
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 +6 -6
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +411 -339
- package/dist/cli.mjs.map +1 -1
- package/dist/structure/rules/root-turbo-json.d.ts +2 -0
- package/package.json +9 -9
- package/src/cmd/software/env.test.ts +3 -7
- package/src/structure/__tests__/root-turbo-json.test.ts +41 -0
- package/src/structure/rules/root-turbo-json.ts +71 -0
- package/src/structure/rules/root.ts +8 -1
- package/src/structure/templates/static/test/.oxfmtrc.json +1 -1
- package/src/structure/templates/static/root/turbo.json +0 -49
package/dist/cli.js
CHANGED
|
@@ -9,16 +9,16 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
9
9
|
`}function O(e){return e===``||e===void 0?[]:e.split(`.`)}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e,t){let n=O(t),r=e;for(let e of n){if(!k(r))return;r=r[e]}return r}function Be(e,t){let n=O(t);if(n.length===0)return!0;let r=e;for(let e=0;e<n.length-1;e++){if(!k(r))return!1;r=r[n[e]]}return k(r)?n[n.length-1]in r:!1}function Ve(e,t,n){let r=O(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(k(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 He(e,t){let n=O(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(!k(r))return;r=r[n[e]]}k(r)&&delete r[n[n.length-1]]}function Ue(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 We(e){let t=e.split(`
|
|
10
10
|
`);return t.length>0&&t[t.length-1]===``&&t.pop(),t}function Ge(e){return e.join(`
|
|
11
11
|
`)+`
|
|
12
|
-
`}function Ke(e){return e.replace(/(^|\s)#.*$/,`$1`).trim()}function qe(e,t){let n=Ke(e);return n===``?!1:n===t.trim()}function Je(e,t){for(let n of e)if(qe(n,t))return!0;return!1}function Ye(e,t){return e===`sdk:`?t?`workspace:*`:`catalog:`:e}var Xe=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function Ze(e,t){if(N(e))for(let n of Xe){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 Qe(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=Qe(e);if(t.kind!==`json`)throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);return t}function M(e){let t=Qe(e);if(t.kind!==`yaml`)throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);return t}function $e(e){let t=Qe(e);if(t.kind!==`lines`)throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);return t}function et(e,t){let n=e.ctx??xe();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 tt(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 nt(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 rt(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}}Te((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){Ve(j(`ensureField`).obj,e,t)}function F(e,t){let n=j(`removeField`).obj;Be(n,e)&&(t&&!t(ze(n,e))||He(n,e))}function it(e,t){let n=j(`requireField`).obj;if(!Be(n,e))throw Error(t??`requireField: missing field '${e}'`)}function I(e,t){P(`scripts.${e}`,t)}function L(e){F(`scripts.${e}`)}var at=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function R(e,t,n,r){let i=j(e),a=i.obj,o=n===`sdk:`?Ye(n,et(i,e).isSdkInternal):n;for(let e of at){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 z(e,t){R(`ensureDep`,e,t,`dependencies`)}function B(e,t){R(`ensureDevDep`,e,t,`devDependencies`)}function ot(e,t){R(`ensurePeerDep`,e,t,`peerDependencies`)}function V(e){let t=j(`removeDep`).obj;for(let n of at){let r=t[n];N(r)&&e in r&&delete r[e]}}function H(e){for(let[t,n]of Object.entries(e))B(t,n)}function U(e){for(let[t,n]of Object.entries(e))ot(t,n)}function st(e,t,n){let r=et(j(e),e);for(let i of r.modules)i.scope===t&&R(e,i.name,`workspace:*`,n)}function ct(e){st(`ensureWorkspaceScopeDeps`,e,`dependencies`)}function lt(e){st(`ensureWorkspaceScopeDevDeps`,e,`devDependencies`)}function ut(e){let t=j(`pruneKeysMatching`).obj;for(let n of Object.keys(t))e(n,t[n])&&delete t[n]}function dt(e,t){let n=Ue(e,t);for(let t of Object.keys(e))delete e[t];for(let t of Object.keys(n))e[t]=n[t]}function W(e){dt(j(`enforceFieldOrder`).obj,e)}function ft(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])&&ft(e[i],!0)}function G(e=``,t={}){let n=t.recursive??!1;if(e===``&&!n)return;let r=j(`enforceAlphabeticalOrder`).obj;if(e===``){ft(r,!0);return}let i=ze(r,e);N(i)&&ft(i,n)}function pt(){let e=M(`ensureWorkspaceModulePaths`),t=et(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 mt(e,t){let n=e.doc.getIn([`catalog`,t]);return typeof n==`string`?n:void 0}function ht(e,t){let n=M(`ensureCatalogVersion`);mt(n,e)===void 0&&n.doc.setIn([`catalog`,e],t)}function gt(e){let t=M(`ensureCatalogLatest`);if(!t.getLatestVersion)return;let n=t.getLatestVersion(e);n!==void 0&&mt(t,e)!==n&&t.doc.setIn([`catalog`,e],n)}function _t(e,t){let n=M(`pinCatalogToDependencyOf`);if(!n.getDerivedDependencyPin)return;let r=n.getDerivedDependencyPin(e);r!==void 0&&mt(n,e)!==r&&n.doc.setIn([`catalog`,e],r)}function vt(e){let t=M(`ensureCatalogAbsent`);t.doc.hasIn([`catalog`,e])&&t.doc.deleteIn([`catalog`,e])}function yt(e){let t=$e(`ensureGitignoreEntries`);for(let n of e)Je(t.lines,n)||t.lines.push(n)}function bt(e){return(0,o.parseDocument)(e)}function xt(e){return e.toString()}var St=`.structure`;function Ct(e){if(!e.exists(`.structure`))return{version:0};try{let t=JSON.parse(e.read(St));return{version:typeof t?.version==`number`?t.version:0}}catch{return{version:0}}}function wt(e,t=0){if(e<t)throw new Tt(e,t)}var Tt=class extends Error{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 Et(e,t){e.write(St,JSON.stringify(t))}var Dt=class extends Error{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 Ot(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 le(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 Ze(n,r.isSdkInternal),Re(n,{collapse:!t.endsWith(`package.json`)});if(t.endsWith(`.yaml`)||t.endsWith(`.yml`))return(0,o.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 kt(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));return}e.write(t,Ot(n,t,r,i))}function At(e,t,n,r,i,a){let o=e.split(`/`).pop()??e;if(e.endsWith(`.json`)){let i=Me(t);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`managed: parsed value at '${e}' is not a JSON object`);return tt(i,n,{triggerContext:r}),Re(i,{collapse:o!==`package.json`})}if(e.endsWith(`.yaml`)||e.endsWith(`.yml`)){let e=bt(t);return nt(e,n,{triggerContext:r,getLatestVersion:i,getDerivedDependencyPin:a}),xt(e)}if(o===`.gitignore`||o.endsWith(`.gitignore`)){let e=We(t);return rt(e,n,{triggerContext:r}),Ge(e)}throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`)}function jt(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 Mt(e,t){let n=t===``?t:t.endsWith(`/`)?t.slice(0,-1):t;return e.has(n)}function Nt(e,t,n){return{ctx:t,version:t.version,pathExists:t=>Mt(e,t),pathMissing:t=>!Mt(e,t),filesMatch:t=>{let r=n?`${n}/${t}`:t;for(let t of e)if(ve(r,t))return!0;return!1}}}function Pt(e,t){for(let n of e.triggers)if(!n(t))return!1;return!0}function Ft(e,t){return t?`init`:e.updateDepsOnly?`updateDeps`:`default`}function It(e,t){return e.filter(e=>e.modes.includes(t))}function Lt(e,t,n,r,i,a){let o=e.leaf;if(o.kind===`fixed`){let i=Ot(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||kt(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||kt(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 Rt(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=Ot(c.initial,l,i,s),f=!0);let p=At(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 zt(e,t,n,r,i,a,o,s){let c=It(e,Ft(n,a)),l=[],u=jt(t);for(let e of c){if(e.leaf.kind===`managed`||!Pt(e,Nt(u,n,e.modulePath)))continue;let o=Lt(e,t,r,i,a,n);o&&l.push(o)}let d=jt(t);for(let e of c){if(e.leaf.kind!==`managed`)continue;let a=Nt(d,n,e.modulePath);if(!Pt(e,a))continue;let c=Rt(e,t,r,a,i,o,s,n);c&&l.push(c)}return l}function Bt(e,t,n,r={}){return be(n,()=>{let i=pe(e,n),a=!!r.initMode,o=zt(i,t,n,n.dryRun,r.templates,a,r.registryLookup,r.derivedPinLookup);if(!n.dryRun&&!n.updateDepsOnly&&!a){Et(t,{version:2});let i={...r.rediscover?r.rediscover(t):n,dryRun:!0},a=zt(pe(e,i),t,i,!0,r.templates,!1,r.registryLookup,r.derivedPinLookup).filter(e=>e.path!==St);if(a.length>0)throw new Dt(a[0])}return a&&!n.dryRun&&Et(t,{version:2}),{changes:o}})}var Vt=[`root`,`block`,`model`,`ui`,`workflow`,`test`,`software`],Ht=class extends Error{constructor(e,t){super(e),this.path=t,this.name=`DiscoveryError`}};function Ut(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 Wt(e){return e===``||e===`.`}function Gt(e){let t=e.pkg[`block-scope`];if(typeof t==`string`){if(!Vt.includes(t))throw new Ht(`package.json "block-scope" must be one of ${Vt.join(`, `)}, got '${t}'`,e.path);return t}if(Wt(e.path))return`root`;if(e.pkg.block!==void 0)return`block`;let n=Ut(e.pkg);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 Kt(e){let t=[];for(let n of e){let e=Gt(n);if(!e)throw new Ht(`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:Wt(n.path)?``:n.path})}return t}function K(e,t){return e.modules.filter(e=>e.scope===t)}function qt(e,t){let n=K(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 Jt(e,t){return{[qt(e,t).name]:`workspace:*`}}function q(e,t){let n={};for(let r of K(e,t))n[r.name]=`workspace:*`;return n}function Yt(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:`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 Xt(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 J=class extends Error{constructor(e){super(e),this.name=`StructureCliError`}};function Zt(e,t){return e===``?t:`${e}/${t}`}function Qt(e,t){try{return JSON.parse(e.read(t))}catch{return}}function $t(e){if(e.includes(`*`))throw new J(`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 en(e){let t;try{t=e.read(`pnpm-workspace.yaml`)}catch{throw new J(`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,o.parse)(t)??{},r=Array.isArray(n.packages)?n.packages:[],i=new Set([``]);for(let t of r){let n=$t(t);(n===``||e.exists(n))&&i.add(n)}let a=[];for(let t of i){let n=Qt(e,Zt(t,`package.json`));n&&a.push({path:t,pkg:n})}return a}function tn(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=Zt(i,s.name),c=Qt(e,Zt(o,`package.json`));c&&t.push({path:o,pkg:c}),a<2&&r(o,a+1)}}return r(``,1),t}function nn(e){let t=e.indexOf(`/`);if(!e.startsWith(`@`)||t<0)throw new J(`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 J(`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 rn(e){let{fs:t,isSdkInternal:n}=e,r=n?tn(t):en(t);if(r.length===0)throw new J(`No workspace packages found. Run 'block-tools structure init' to scaffold a block.`);let i=Kt(r),a=Ct(t);wt(a.version,0);let o=i.find(e=>e.scope===`block`)??i.find(e=>e.scope===`root`);if(!o)throw new J(`Could not find a 'block' (or root-as-block) package to derive BlockVars from.`);let s=nn(o.name.replace(/\.block$/,``));return Xt({isSdkInternal:n,updateDepsOnly:e.updateDepsOnly??!1,modules:i,blockVars:s,version:a.version,dryRun:e.dryRun??!1})}var Y=[`name`,`version`,`private`,`description`,`keywords`,`files`,`type`,`main`,`module`,`types`,`exports`,`scripts`,`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`,`packageManager`,`pnpm`,`block`,`block-software`],an={"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`},on={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 sn(){return{version:`1.0.0`,private:!0,scripts:{fmt:`turbo run fmt`,check:`turbo run check`,...an,...on,"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:`},packageManager:`pnpm@9.12.0`}}function cn(){P(`packageManager`,`pnpm@9.12.0`),F(`name`),I(`fmt`,`turbo run fmt`),I(`check`,`turbo run check`);for(let[e,t]of Object.entries(an))I(e,t);for(let[e,t]of Object.entries(on))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`),H({"@changesets/cli":`catalog:`,"@milaboratories/ts-builder":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,shx:`catalog:`,turbo:`catalog:`}),U({oxlint:`*`,oxfmt:`*`}),ut((e,t)=>{if(!/^(\/\/|--)/.test(e)||typeof t!=`object`||!t)return!1;let n=t;return n.pnpm!==void 0||n.overrides!==void 0}),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}var ln=2,un=500,dn=3e4;function fn(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(dn)})}catch(e){if(t>ln)throw e;await(0,s.setTimeout)(un*2**(t-1)*(.8+.4*Math.random()));continue}if(n.ok)return n;if(!(n.status===429||n.status>=500)||t>ln)throw Error(`registry returned HTTP ${n.status}`);let r=fn(n.headers.get(`retry-after`));if(r!=null){await(0,s.setTimeout)(r);continue}await(0,s.setTimeout)(un*2**(t-1)*(.8+.4*Math.random()))}}function mn(){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 hn(e,t){let n=await Promise.all(t.map(async t=>[t,await e.getLatestVersion(t)]));return new Map(n)}function gn(e){return t=>e.get(t)}var _n=[/^@platforma-sdk\//,/^@milaboratories\//];function vn(e){return _n.some(t=>t.test(e))}async function yn(e,t=mn()){return e.length===0?()=>void 0:gn(await hn(t,e))}function bn(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e)}async function xn(e,t=mn()){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(!bn(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 Sn=[`vite`,`tsup`,`vue-tsc`,`@vitejs/plugin-vue`,`vite-plugin-dts`,`@platforma-sdk/eslint-config`];function X(){for(let e of Sn)V(e)}var Z=[`@platforma-sdk/model`,`@platforma-sdk/ui-vue`,`@platforma-sdk/workflow-tengo`,`@platforma-sdk/test`,`@platforma-sdk/block-tools`,`@platforma-sdk/tengo-builder`,`@platforma-sdk/package-builder`,`@milaboratories/ts-builder`,`@milaboratories/ts-configs`],Cn=`0.0.0-init-must-fetch`;for(let e of Z)if(!vn(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 wn={turbo:`~2.8.11`,shx:`~0.4.0`,"@changesets/cli":`~2.29.8`,vitest:`~4.0.18`},Tn=[{entry:`vue`,of:`@platforma-sdk/ui-vue`},{entry:`@milaboratories/helpers`,of:`@platforma-sdk/model`}],En=`@platforma-open/milaboratories.runenv-python-3`,Dn=`1.8.2`;function On(e){let t=e.modules.filter(e=>e.path!==``).map(e=>e.path).sort(),n={};for(let e of Z)n[e]=Cn;return Object.assign(n,wn),e.modules.some(e=>e.scope===`software`)&&(n[En]=Dn),{packages:t,catalog:n}}function kn(){pt();for(let e of Sn)vt(e)}var An=[`.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 jn(){yt(An)}function Mn(){_(`root`,()=>{v(({ctx:e})=>!e.isSdkInternal,()=>{b(`turbo.json`,T(`root/turbo.json`)),b(`.vscode/settings.json`,T(`root/.vscode/settings.json`)),x(`package.json`,D(()=>sn()),()=>{cn()}),x(`pnpm-workspace.yaml`,D(e=>On(e)),()=>{kn()}),x(`.gitignore`,T(`root/.gitignore`),()=>{jn()})})})}function Nn(e){return e.split(/[-_]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Pn(){_(`root`,()=>{v(({ctx:e})=>!e.isSdkInternal,()=>{b(`.github/workflows/build.yaml`,E(`workflows/build.tpl.yaml`,e=>{let t=e.blockVars.shortName;return{appName:`Block: ${Nn(t)}`,appNameSlug:`block-${t}`}})),b(`.github/workflows/mark-stable.yaml`,E(`workflows/mark-stable.tpl.yaml`,e=>({appName:`Block: ${Nn(e.blockVars.shortName)} - Mark Stable`})))})})}var Fn={"@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`}},In={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://blocks.pl-open.science`},Ln={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1`,serveUrl:`https://aux-blocks.pl-open.science`};function Rn(e,t){let n=t?Ln:Fn[e]??In;return`block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`}function zn(e){let t={};for(let n of K(e,`workflow`))t.workflow=`${n.name}/dist/tengo/tpl/main.plj.gz`;for(let n of K(e,`model`))t.model=`${n.name}/dist/model.json`;for(let n of K(e,`ui`))t.ui=`${n.name}/dist`;return t}function Bn(e,t){return{build:`ts-builder build --target block-facade && block-tools pack`,check:`ts-builder type-check --target block-facade`,prepublishOnly:Rn(e,t),"do-pack":`shx rm -f package.tgz && pnpm pack && shx mv *.tgz package.tgz`}}var Vn={"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,"@platforma-sdk/model":`sdk:`,shx:`catalog:`,typescript:`catalog:`},Hn={".":{sources:`./src/index.ts`,types:`./dist/index.d.ts`,default:`./dist/index.js`}};function Un(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 Wn(e){let t=e.blockVars,n={...Vn,...q(e,`model`),...q(e,`ui`),...q(e,`workflow`)},r={components:zn(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 Un(r),{name:`${t.facadeName}.block`,version:`1.0.0`,type:`module`,files:[`dist`,`block-pack`],main:`./dist/index.js`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:Hn,scripts:Bn(t.npmOrg,e.isSdkInternal),dependencies:{},devDependencies:n,block:r}}function Gn(e){let t=e.blockVars;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`,Hn);let n=Bn(t.npmOrg,e.isSdkInternal);for(let[e,t]of Object.entries(n))I(e,t);L(`mark-stable`),lt(`model`),lt(`ui`),lt(`workflow`),B(`@milaboratories/ts-builder`,`sdk:`),B(`@milaboratories/ts-configs`,`sdk:`),B(`@platforma-sdk/block-tools`,`sdk:`),B(`@platforma-sdk/model`,`sdk:`),B(`shx`,`catalog:`),B(`typescript`,`catalog:`),P(`block.components`,zn(e)),it(`version`,`facade package.json must carry a 'version' (the facade publishes)`),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function Kn(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 qn(){_(`block`,()=>{w(`index.js`),w(`index.d.ts`),b(`src/index.ts`,E(`block/src/index.tpl.ts`,e=>({facadeName:e.blockVars.facadeName,pascalName:Kn(e.blockVars.shortName)}))),b(`src/AGENTS.ts`,T(`block/src/AGENTS.ts`)),S(`src/block-extra.ts`,T(`block/src/block-extra.ts`)),S(`src/agents-extra.ts`,T(`block/src/agents-extra.ts`)),b(`tsconfig.json`,T(`block/tsconfig.json`)),C(`logos/block-logo.png`,Ae(`block/logos/block-logo.png`)),C(`logos/organization-logo.png`,Ae(`block/logos/organization-logo.png`)),x(`package.json`,D(e=>Wn(e)),e=>{Gn(e)})})}var Q=`src/**/*.test.ts`;function Jn(e){return{name:`${e.blockVars.facadeName}.model`,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:`},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Yn(){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`),z(`@platforma-sdk/model`,`sdk:`),H({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`}),U({"@types/node":`*`,typescript:`*`}),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{I(`test`,`vitest run --passWithNoTests`),B(`vitest`,`catalog:`),B(`@types/node`,`*`)},()=>V(`vitest`))),X(),F(`tsup`),L(`lint`),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function Xn(){_(`model`,()=>{v(y(Q),()=>b(`tsconfig.json`,T(`model/tsconfig.node.json`)),()=>b(`tsconfig.json`,T(`model/tsconfig.json`))),b(`.oxlintrc.json`,T(`model/.oxlintrc.json`)),b(`.oxfmtrc.json`,T(`model/.oxfmtrc.json`)),C(`src/index.ts`,T(`model/src/index.ts`)),x(`package.json`,D(e=>Jn(e)),()=>{Yn()})})}function Zn(e){return{name:`${e.blockVars.facadeName}.ui`,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:`,...Jt(e,`model`)},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function Qn(){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`),z(`@platforma-sdk/ui-vue`,`sdk:`),z(`vue`,`catalog:`),ct(`model`),H({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`}),X(),L(`preview`),L(`lint`),U({"@types/node":`*`,typescript:`*`}),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{I(`test`,`vitest run --passWithNoTests`),B(`vitest`,`catalog:`),B(`@types/node`,`*`)},()=>V(`vitest`))),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function $n(){_(`ui`,()=>{v(y(Q),()=>b(`tsconfig.json`,T(`ui/tsconfig.node.json`)),()=>b(`tsconfig.json`,T(`ui/tsconfig.json`))),b(`.oxlintrc.json`,T(`ui/.oxlintrc.json`)),b(`.oxfmtrc.json`,T(`ui/.oxfmtrc.json`)),S(`index.html`,T(`ui/index.html`)),C(`src/main.ts`,T(`ui/src/main.ts`)),C(`src/app.ts`,E(`ui/src/app.tpl.ts`,e=>({modelPkg:`${e.blockVars.facadeName}.model`}))),C(`src/MainPage.vue`,E(`ui/src/MainPage.tpl.vue`,e=>({shortName:e.blockVars.shortName}))),x(`package.json`,D(e=>Zn(e)),()=>{Qn()})})}function er(e){return{name:`${e.blockVars.facadeName}.workflow`,private:!0,type:`module`,scripts:{build:`shx rm -rf dist && pl-tengo build`,check:`pl-tengo check`,format:`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`},dependencies:{"@platforma-sdk/workflow-tengo":`sdk:`,...q(e,`software`)},devDependencies:{"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}}}function tr(){P(`private`,!0),P(`type`,`module`),I(`build`,`shx rm -rf dist && pl-tengo build`),I(`check`,`pl-tengo check`),I(`format`,`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{I(`test`,`vitest run --passWithNoTests`),H({vitest:`catalog:`})},()=>V(`vitest`))),z(`@platforma-sdk/workflow-tengo`,`sdk:`),ct(`software`),H({"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}),X(),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function nr(){_(`workflow`,()=>{b(`format.el`,T(`workflow/format.el`)),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{b(`tsconfig.json`,T(`workflow/tsconfig.json`)),S(`vitest.config.mts`,T(`workflow/vitest.config.mts`))},()=>{w(`tsconfig.json`),w(`vitest.config.mts`)})),w(`index.js`),w(`index.d.ts`),C(`src/main.tpl.tengo`,E(`workflow/src/main.tpl.tengo`,e=>({shortName:e.blockVars.shortName}))),x(`package.json`,D(e=>er(e)),()=>{tr()})})}function rr(e){return{name:`${e.blockVars.facadeName}.test`,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 ir(){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`),H({"@platforma-sdk/test":`sdk:`,"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,vitest:`catalog:`}),U({typescript:`*`}),V(`@types/node`),X(),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function ar(){_(`test`,()=>{b(`tsconfig.json`,T(`test/tsconfig.json`)),b(`.oxlintrc.json`,T(`test/.oxlintrc.json`)),b(`.oxfmtrc.json`,T(`test/.oxfmtrc.json`)),S(`vitest.config.mts`,T(`test/vitest.config.mts`)),C(`src/demo.test.ts`,je(`import { expect, test } from "vitest";
|
|
12
|
+
`}function Ke(e){return e.replace(/(^|\s)#.*$/,`$1`).trim()}function qe(e,t){let n=Ke(e);return n===``?!1:n===t.trim()}function Je(e,t){for(let n of e)if(qe(n,t))return!0;return!1}function Ye(e,t){return e===`sdk:`?t?`workspace:*`:`catalog:`:e}var Xe=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function Ze(e,t){if(N(e))for(let n of Xe){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 Qe(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=Qe(e);if(t.kind!==`json`)throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);return t}function M(e){let t=Qe(e);if(t.kind!==`yaml`)throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);return t}function $e(e){let t=Qe(e);if(t.kind!==`lines`)throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);return t}function et(e,t){let n=e.ctx??xe();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 tt(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 nt(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 rt(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}}Te((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){Ve(j(`ensureField`).obj,e,t)}function F(e,t){let n=j(`removeField`).obj;Be(n,e)&&(t&&!t(ze(n,e))||He(n,e))}function it(e,t){let n=j(`requireField`).obj;if(!Be(n,e))throw Error(t??`requireField: missing field '${e}'`)}function at(e,t){let n=j(`ensureFieldEntries`).obj,r=Be(n,e)?ze(n,e):void 0,i=N(r)?r:{};for(let[e,n]of Object.entries(t))i[e]=n;N(r)||Ve(n,e,i)}function I(e,t){P(`scripts.${e}`,t)}function L(e){F(`scripts.${e}`)}var ot=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`];function R(e,t,n,r){let i=j(e),a=i.obj,o=n===`sdk:`?Ye(n,et(i,e).isSdkInternal):n;for(let e of ot){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 z(e,t){R(`ensureDep`,e,t,`dependencies`)}function B(e,t){R(`ensureDevDep`,e,t,`devDependencies`)}function st(e,t){R(`ensurePeerDep`,e,t,`peerDependencies`)}function V(e){let t=j(`removeDep`).obj;for(let n of ot){let r=t[n];N(r)&&e in r&&delete r[e]}}function H(e){for(let[t,n]of Object.entries(e))B(t,n)}function U(e){for(let[t,n]of Object.entries(e))st(t,n)}function ct(e,t,n){let r=et(j(e),e);for(let i of r.modules)i.scope===t&&R(e,i.name,`workspace:*`,n)}function lt(e){ct(`ensureWorkspaceScopeDeps`,e,`dependencies`)}function ut(e){ct(`ensureWorkspaceScopeDevDeps`,e,`devDependencies`)}function dt(e){let t=j(`pruneKeysMatching`).obj;for(let n of Object.keys(t))e(n,t[n])&&delete t[n]}function ft(e,t){let n=Ue(e,t);for(let t of Object.keys(e))delete e[t];for(let t of Object.keys(n))e[t]=n[t]}function W(e){ft(j(`enforceFieldOrder`).obj,e)}function pt(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])&&pt(e[i],!0)}function G(e=``,t={}){let n=t.recursive??!1;if(e===``&&!n)return;let r=j(`enforceAlphabeticalOrder`).obj;if(e===``){pt(r,!0);return}let i=ze(r,e);N(i)&&pt(i,n)}function mt(){let e=M(`ensureWorkspaceModulePaths`),t=et(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 ht(e,t){let n=e.doc.getIn([`catalog`,t]);return typeof n==`string`?n:void 0}function gt(e,t){let n=M(`ensureCatalogVersion`);ht(n,e)===void 0&&n.doc.setIn([`catalog`,e],t)}function _t(e){let t=M(`ensureCatalogLatest`);if(!t.getLatestVersion)return;let n=t.getLatestVersion(e);n!==void 0&&ht(t,e)!==n&&t.doc.setIn([`catalog`,e],n)}function vt(e,t){let n=M(`pinCatalogToDependencyOf`);if(!n.getDerivedDependencyPin)return;let r=n.getDerivedDependencyPin(e);r!==void 0&&ht(n,e)!==r&&n.doc.setIn([`catalog`,e],r)}function yt(e){let t=M(`ensureCatalogAbsent`);t.doc.hasIn([`catalog`,e])&&t.doc.deleteIn([`catalog`,e])}function bt(e){let t=$e(`ensureGitignoreEntries`);for(let n of e)Je(t.lines,n)||t.lines.push(n)}function xt(e){return(0,o.parseDocument)(e)}function St(e){return e.toString()}var Ct=`.structure`;function wt(e){if(!e.exists(`.structure`))return{version:0};try{let t=JSON.parse(e.read(Ct));return{version:typeof t?.version==`number`?t.version:0}}catch{return{version:0}}}function Tt(e,t=0){if(e<t)throw new Et(e,t)}var Et=class extends Error{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 Dt(e,t){e.write(Ct,JSON.stringify(t))}var Ot=class extends Error{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 kt(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 le(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 Ze(n,r.isSdkInternal),Re(n,{collapse:!t.endsWith(`package.json`)});if(t.endsWith(`.yaml`)||t.endsWith(`.yml`))return(0,o.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 At(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));return}e.write(t,kt(n,t,r,i))}function jt(e,t,n,r,i,a){let o=e.split(`/`).pop()??e;if(e.endsWith(`.json`)){let i=Me(t);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`managed: parsed value at '${e}' is not a JSON object`);return tt(i,n,{triggerContext:r}),Re(i,{collapse:o!==`package.json`})}if(e.endsWith(`.yaml`)||e.endsWith(`.yml`)){let e=xt(t);return nt(e,n,{triggerContext:r,getLatestVersion:i,getDerivedDependencyPin:a}),St(e)}if(o===`.gitignore`||o.endsWith(`.gitignore`)){let e=We(t);return rt(e,n,{triggerContext:r}),Ge(e)}throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`)}function Mt(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 Nt(e,t){let n=t===``?t:t.endsWith(`/`)?t.slice(0,-1):t;return e.has(n)}function Pt(e,t,n){return{ctx:t,version:t.version,pathExists:t=>Nt(e,t),pathMissing:t=>!Nt(e,t),filesMatch:t=>{let r=n?`${n}/${t}`:t;for(let t of e)if(ve(r,t))return!0;return!1}}}function Ft(e,t){for(let n of e.triggers)if(!n(t))return!1;return!0}function It(e,t){return t?`init`:e.updateDepsOnly?`updateDeps`:`default`}function Lt(e,t){return e.filter(e=>e.modes.includes(t))}function Rt(e,t,n,r,i,a){let o=e.leaf;if(o.kind===`fixed`){let i=kt(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||At(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||At(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 zt(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=kt(c.initial,l,i,s),f=!0);let p=jt(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 Bt(e,t,n,r,i,a,o,s){let c=Lt(e,It(n,a)),l=[],u=Mt(t);for(let e of c){if(e.leaf.kind===`managed`||!Ft(e,Pt(u,n,e.modulePath)))continue;let o=Rt(e,t,r,i,a,n);o&&l.push(o)}let d=Mt(t);for(let e of c){if(e.leaf.kind!==`managed`)continue;let a=Pt(d,n,e.modulePath);if(!Ft(e,a))continue;let c=zt(e,t,r,a,i,o,s,n);c&&l.push(c)}return l}function Vt(e,t,n,r={}){return be(n,()=>{let i=pe(e,n),a=!!r.initMode,o=Bt(i,t,n,n.dryRun,r.templates,a,r.registryLookup,r.derivedPinLookup);if(!n.dryRun&&!n.updateDepsOnly&&!a){Dt(t,{version:2});let i={...r.rediscover?r.rediscover(t):n,dryRun:!0},a=Bt(pe(e,i),t,i,!0,r.templates,!1,r.registryLookup,r.derivedPinLookup).filter(e=>e.path!==Ct);if(a.length>0)throw new Ot(a[0])}return a&&!n.dryRun&&Dt(t,{version:2}),{changes:o}})}var Ht=[`root`,`block`,`model`,`ui`,`workflow`,`test`,`software`],Ut=class extends Error{constructor(e,t){super(e),this.path=t,this.name=`DiscoveryError`}};function Wt(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 Gt(e){return e===``||e===`.`}function Kt(e){let t=e.pkg[`block-scope`];if(typeof t==`string`){if(!Ht.includes(t))throw new Ut(`package.json "block-scope" must be one of ${Ht.join(`, `)}, got '${t}'`,e.path);return t}if(Gt(e.path))return`root`;if(e.pkg.block!==void 0)return`block`;let n=Wt(e.pkg);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 qt(e){let t=[];for(let n of e){let e=Kt(n);if(!e)throw new Ut(`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:Gt(n.path)?``:n.path})}return t}function K(e,t){return e.modules.filter(e=>e.scope===t)}function Jt(e,t){let n=K(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 Yt(e,t){return{[Jt(e,t).name]:`workspace:*`}}function q(e,t){let n={};for(let r of K(e,t))n[r.name]=`workspace:*`;return n}function Xt(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:`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 Zt(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 J=class extends Error{constructor(e){super(e),this.name=`StructureCliError`}};function Qt(e,t){return e===``?t:`${e}/${t}`}function $t(e,t){try{return JSON.parse(e.read(t))}catch{return}}function en(e){if(e.includes(`*`))throw new J(`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 tn(e){let t;try{t=e.read(`pnpm-workspace.yaml`)}catch{throw new J(`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,o.parse)(t)??{},r=Array.isArray(n.packages)?n.packages:[],i=new Set([``]);for(let t of r){let n=en(t);(n===``||e.exists(n))&&i.add(n)}let a=[];for(let t of i){let n=$t(e,Qt(t,`package.json`));n&&a.push({path:t,pkg:n})}return a}function nn(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=Qt(i,s.name),c=$t(e,Qt(o,`package.json`));c&&t.push({path:o,pkg:c}),a<2&&r(o,a+1)}}return r(``,1),t}function rn(e){let t=e.indexOf(`/`);if(!e.startsWith(`@`)||t<0)throw new J(`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 J(`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 an(e){let{fs:t,isSdkInternal:n}=e,r=n?nn(t):tn(t);if(r.length===0)throw new J(`No workspace packages found. Run 'block-tools structure init' to scaffold a block.`);let i=qt(r),a=wt(t);Tt(a.version,0);let o=i.find(e=>e.scope===`block`)??i.find(e=>e.scope===`root`);if(!o)throw new J(`Could not find a 'block' (or root-as-block) package to derive BlockVars from.`);let s=rn(o.name.replace(/\.block$/,``));return Zt({isSdkInternal:n,updateDepsOnly:e.updateDepsOnly??!1,modules:i,blockVars:s,version:a.version,dryRun:e.dryRun??!1})}var Y=[`name`,`version`,`private`,`description`,`keywords`,`files`,`type`,`main`,`module`,`types`,`exports`,`scripts`,`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`,`packageManager`,`pnpm`,`block`,`block-software`],on={"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:`1.0.0`,private:!0,scripts:{fmt:`turbo run fmt`,check:`turbo run check`,...on,...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:`},packageManager:`pnpm@9.12.0`}}function ln(){P(`packageManager`,`pnpm@9.12.0`),F(`name`),I(`fmt`,`turbo run fmt`),I(`check`,`turbo run check`);for(let[e,t]of Object.entries(on))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`),H({"@changesets/cli":`catalog:`,"@milaboratories/ts-builder":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,shx:`catalog:`,turbo:`catalog:`}),U({oxlint:`*`,oxfmt:`*`}),dt((e,t)=>{if(!/^(\/\/|--)/.test(e)||typeof t!=`object`||!t)return!1;let n=t;return n.pnpm!==void 0||n.overrides!==void 0}),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}var un=`https://turbo.build/schema.json`,dn=[`tsconfig.json`],fn={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 pn(){return{$schema:un,globalDependencies:dn,tasks:{...fn}}}function mn(){P(`$schema`,un),P(`globalDependencies`,dn),at(`tasks`,fn),F(`tasks.build:dev`),W([`$schema`,`globalDependencies`,`tasks`])}var hn=2,gn=500,_n=3e4;function vn(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 yn(e){for(let t=1;;t++){let n;try{n=await fetch(e,{signal:AbortSignal.timeout(_n)})}catch(e){if(t>hn)throw e;await(0,s.setTimeout)(gn*2**(t-1)*(.8+.4*Math.random()));continue}if(n.ok)return n;if(!(n.status===429||n.status>=500)||t>hn)throw Error(`registry returned HTTP ${n.status}`);let r=vn(n.headers.get(`retry-after`));if(r!=null){await(0,s.setTimeout)(r);continue}await(0,s.setTimeout)(gn*2**(t-1)*(.8+.4*Math.random()))}}function bn(){return{async getLatestVersion(e){let t=(await(await yn(`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 yn(`https://registry.npmjs.org/${e}/${t}`)).json();return r.dependencies?.[n]??r.peerDependencies?.[n]}}}async function xn(e,t){let n=await Promise.all(t.map(async t=>[t,await e.getLatestVersion(t)]));return new Map(n)}function Sn(e){return t=>e.get(t)}var Cn=[/^@platforma-sdk\//,/^@milaboratories\//];function wn(e){return Cn.some(t=>t.test(e))}async function Tn(e,t=bn()){return e.length===0?()=>void 0:Sn(await xn(t,e))}function En(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e)}async function Dn(e,t=bn()){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(!En(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 On=[`vite`,`tsup`,`vue-tsc`,`@vitejs/plugin-vue`,`vite-plugin-dts`,`@platforma-sdk/eslint-config`];function X(){for(let e of On)V(e)}var Z=[`@platforma-sdk/model`,`@platforma-sdk/ui-vue`,`@platforma-sdk/workflow-tengo`,`@platforma-sdk/test`,`@platforma-sdk/block-tools`,`@platforma-sdk/tengo-builder`,`@platforma-sdk/package-builder`,`@milaboratories/ts-builder`,`@milaboratories/ts-configs`],kn=`0.0.0-init-must-fetch`;for(let e of Z)if(!wn(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 An={turbo:`~2.8.11`,shx:`~0.4.0`,"@changesets/cli":`~2.29.8`,vitest:`~4.0.18`},jn=[{entry:`vue`,of:`@platforma-sdk/ui-vue`},{entry:`@milaboratories/helpers`,of:`@platforma-sdk/model`}],Mn=`@platforma-open/milaboratories.runenv-python-3`,Nn=`1.8.2`;function Pn(e){let t=e.modules.filter(e=>e.path!==``).map(e=>e.path).sort(),n={};for(let e of Z)n[e]=kn;return Object.assign(n,An),e.modules.some(e=>e.scope===`software`)&&(n[Mn]=Nn),{packages:t,catalog:n}}function Fn(){mt();for(let e of On)yt(e)}var In=[`.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 Ln(){bt(In)}function Rn(){_(`root`,()=>{v(({ctx:e})=>!e.isSdkInternal,()=>{x(`turbo.json`,D(()=>pn()),()=>{mn()}),b(`.vscode/settings.json`,T(`root/.vscode/settings.json`)),x(`package.json`,D(()=>cn()),()=>{ln()}),x(`pnpm-workspace.yaml`,D(e=>Pn(e)),()=>{Fn()}),x(`.gitignore`,T(`root/.gitignore`),()=>{Ln()})})})}function zn(e){return e.split(/[-_]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Bn(){_(`root`,()=>{v(({ctx:e})=>!e.isSdkInternal,()=>{b(`.github/workflows/build.yaml`,E(`workflows/build.tpl.yaml`,e=>{let t=e.blockVars.shortName;return{appName:`Block: ${zn(t)}`,appNameSlug:`block-${t}`}})),b(`.github/workflows/mark-stable.yaml`,E(`workflows/mark-stable.tpl.yaml`,e=>({appName:`Block: ${zn(e.blockVars.shortName)} - Mark Stable`})))})})}var Vn={"@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`}},Hn={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1`,serveUrl:`https://blocks.pl-open.science`},Un={s3:`s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1`,serveUrl:`https://aux-blocks.pl-open.science`};function Wn(e,t){let n=t?Un:Vn[e]??Hn;return`block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`}function Gn(e){let t={};for(let n of K(e,`workflow`))t.workflow=`${n.name}/dist/tengo/tpl/main.plj.gz`;for(let n of K(e,`model`))t.model=`${n.name}/dist/model.json`;for(let n of K(e,`ui`))t.ui=`${n.name}/dist`;return t}function Kn(e,t){return{build:`ts-builder build --target block-facade && block-tools pack`,check:`ts-builder type-check --target block-facade`,prepublishOnly:Wn(e,t),"do-pack":`shx rm -f package.tgz && pnpm pack && shx mv *.tgz package.tgz`}}var qn={"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`,"@platforma-sdk/model":`sdk:`,shx:`catalog:`,typescript:`catalog:`},Jn={".":{sources:`./src/index.ts`,types:`./dist/index.d.ts`,default:`./dist/index.js`}};function Yn(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 Xn(e){let t=e.blockVars,n={...qn,...q(e,`model`),...q(e,`ui`),...q(e,`workflow`)},r={components:Gn(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 Yn(r),{name:`${t.facadeName}.block`,version:`1.0.0`,type:`module`,files:[`dist`,`block-pack`],main:`./dist/index.js`,module:`./dist/index.js`,types:`./dist/index.d.ts`,exports:Jn,scripts:Kn(t.npmOrg,e.isSdkInternal),dependencies:{},devDependencies:n,block:r}}function Zn(e){let t=e.blockVars;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`,Jn);let n=Kn(t.npmOrg,e.isSdkInternal);for(let[e,t]of Object.entries(n))I(e,t);L(`mark-stable`),ut(`model`),ut(`ui`),ut(`workflow`),B(`@milaboratories/ts-builder`,`sdk:`),B(`@milaboratories/ts-configs`,`sdk:`),B(`@platforma-sdk/block-tools`,`sdk:`),B(`@platforma-sdk/model`,`sdk:`),B(`shx`,`catalog:`),B(`typescript`,`catalog:`),P(`block.components`,Gn(e)),it(`version`,`facade package.json must carry a 'version' (the facade publishes)`),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function Qn(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 $n(){_(`block`,()=>{w(`index.js`),w(`index.d.ts`),b(`src/index.ts`,E(`block/src/index.tpl.ts`,e=>({facadeName:e.blockVars.facadeName,pascalName:Qn(e.blockVars.shortName)}))),b(`src/AGENTS.ts`,T(`block/src/AGENTS.ts`)),S(`src/block-extra.ts`,T(`block/src/block-extra.ts`)),S(`src/agents-extra.ts`,T(`block/src/agents-extra.ts`)),b(`tsconfig.json`,T(`block/tsconfig.json`)),C(`logos/block-logo.png`,Ae(`block/logos/block-logo.png`)),C(`logos/organization-logo.png`,Ae(`block/logos/organization-logo.png`)),x(`package.json`,D(e=>Xn(e)),e=>{Zn(e)})})}var Q=`src/**/*.test.ts`;function er(e){return{name:`${e.blockVars.facadeName}.model`,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:`},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function tr(){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`),z(`@platforma-sdk/model`,`sdk:`),H({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,"@platforma-sdk/block-tools":`sdk:`}),U({"@types/node":`*`,typescript:`*`}),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{I(`test`,`vitest run --passWithNoTests`),B(`vitest`,`catalog:`),B(`@types/node`,`*`)},()=>V(`vitest`))),X(),F(`tsup`),L(`lint`),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function nr(){_(`model`,()=>{v(y(Q),()=>b(`tsconfig.json`,T(`model/tsconfig.node.json`)),()=>b(`tsconfig.json`,T(`model/tsconfig.json`))),b(`.oxlintrc.json`,T(`model/.oxlintrc.json`)),b(`.oxfmtrc.json`,T(`model/.oxfmtrc.json`)),C(`src/index.ts`,T(`model/src/index.ts`)),x(`package.json`,D(e=>er(e)),()=>{tr()})})}function rr(e){return{name:`${e.blockVars.facadeName}.ui`,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:`,...Yt(e,`model`)},devDependencies:{"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`},peerDependencies:{"@types/node":`*`,typescript:`*`}}}function ir(){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`),z(`@platforma-sdk/ui-vue`,`sdk:`),z(`vue`,`catalog:`),lt(`model`),H({"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`}),X(),L(`preview`),L(`lint`),U({"@types/node":`*`,typescript:`*`}),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{I(`test`,`vitest run --passWithNoTests`),B(`vitest`,`catalog:`),B(`@types/node`,`*`)},()=>V(`vitest`))),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function ar(){_(`ui`,()=>{v(y(Q),()=>b(`tsconfig.json`,T(`ui/tsconfig.node.json`)),()=>b(`tsconfig.json`,T(`ui/tsconfig.json`))),b(`.oxlintrc.json`,T(`ui/.oxlintrc.json`)),b(`.oxfmtrc.json`,T(`ui/.oxfmtrc.json`)),S(`index.html`,T(`ui/index.html`)),C(`src/main.ts`,T(`ui/src/main.ts`)),C(`src/app.ts`,E(`ui/src/app.tpl.ts`,e=>({modelPkg:`${e.blockVars.facadeName}.model`}))),C(`src/MainPage.vue`,E(`ui/src/MainPage.tpl.vue`,e=>({shortName:e.blockVars.shortName}))),x(`package.json`,D(e=>rr(e)),()=>{ir()})})}function or(e){return{name:`${e.blockVars.facadeName}.workflow`,private:!0,type:`module`,scripts:{build:`shx rm -rf dist && pl-tengo build`,check:`pl-tengo check`,format:`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`},dependencies:{"@platforma-sdk/workflow-tengo":`sdk:`,...q(e,`software`)},devDependencies:{"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}}}function sr(){P(`private`,!0),P(`type`,`module`),I(`build`,`shx rm -rf dist && pl-tengo build`),I(`check`,`pl-tengo check`),I(`format`,`/usr/bin/env emacs --script ./format.el || echo 'No emacs.'`),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{I(`test`,`vitest run --passWithNoTests`),H({vitest:`catalog:`})},()=>V(`vitest`))),z(`@platforma-sdk/workflow-tengo`,`sdk:`),lt(`software`),H({"@platforma-sdk/tengo-builder":`sdk:`,"@platforma-sdk/test":`sdk:`,shx:`catalog:`}),X(),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function cr(){_(`workflow`,()=>{b(`format.el`,T(`workflow/format.el`)),v(({ctx:e})=>!e.isSdkInternal,()=>v(y(Q),()=>{b(`tsconfig.json`,T(`workflow/tsconfig.json`)),S(`vitest.config.mts`,T(`workflow/vitest.config.mts`))},()=>{w(`tsconfig.json`),w(`vitest.config.mts`)})),w(`index.js`),w(`index.d.ts`),C(`src/main.tpl.tengo`,E(`workflow/src/main.tpl.tengo`,e=>({shortName:e.blockVars.shortName}))),x(`package.json`,D(e=>or(e)),()=>{sr()})})}function lr(e){return{name:`${e.blockVars.facadeName}.test`,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(){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`),H({"@platforma-sdk/test":`sdk:`,"@milaboratories/ts-builder":`sdk:`,"@milaboratories/ts-configs":`sdk:`,vitest:`catalog:`}),U({typescript:`*`}),V(`@types/node`),X(),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}function dr(){_(`test`,()=>{b(`tsconfig.json`,T(`test/tsconfig.json`)),b(`.oxlintrc.json`,T(`test/.oxlintrc.json`)),b(`.oxfmtrc.json`,T(`test/.oxfmtrc.json`)),S(`vitest.config.mts`,T(`test/vitest.config.mts`)),C(`src/demo.test.ts`,je(`import { expect, test } from "vitest";
|
|
13
13
|
|
|
14
14
|
test("scaffolded block sanity check", () => {
|
|
15
15
|
expect(true).toBe(true);
|
|
16
16
|
});
|
|
17
|
-
`)),x(`package.json`,D(e=>
|
|
17
|
+
`)),x(`package.json`,D(e=>lr(e)),()=>{ur()})})}var fr=`block-tools software build`,pr=`shx rm -f *.tgz && block-tools software build && pnpm pack && shx mv platforma-open*.tgz package.tgz`;function mr(){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 hr(e){return{name:`${e.blockVars.facadeName}.software`,type:`module`,description:`Block Software`,files:[`./dist/**/*`],scripts:{build:fr,"do-pack":pr,changeset:`changeset`,"version-packages":`changeset version`},"block-software":mr(),devDependencies:{"@platforma-open/milaboratories.runenv-python-3":`catalog:`,"@platforma-sdk/block-tools":`sdk:`}}}function gr(){F(`private`),P(`type`,`module`),P(`files`,[`./dist/**/*`]),I(`build`,fr),I(`do-pack`,pr),L(`prepublishOnly`),I(`changeset`,`changeset`),I(`version-packages`,`changeset version`),B(`@platforma-open/milaboratories.runenv-python-3`,`catalog:`),B(`@platforma-sdk/block-tools`,`sdk:`),V(`@platforma-sdk/package-builder`),G(`dependencies`),G(`devDependencies`),G(`peerDependencies`),G(`optionalDependencies`),W([...Y])}var _r=`import sys
|
|
18
18
|
|
|
19
19
|
print("Hello from Python, " + sys.argv[1] + "!")
|
|
20
|
-
`,
|
|
21
|
-
`;function
|
|
22
|
-
`)}`}async function
|
|
23
|
-
`)||` (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 r.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 Tr(e){let t=e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);if(t){let{src:e,destName:n}=t.groups;return{src:e,destName:n}}else return{src:e,destName:n.default.basename(e)}}function Er(e,n){return new t.Option(e,n).argParser((e,t)=>[...t??[],Tr(e)]).default([])}var Dr=[`registry`,`organization`,`package`,`version`];function Or(){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(Er(`-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 a.ConsoleLoggerAdapter,i=e.p.parse({});for(let e of Dr)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=o.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 s=await e.n(i);n.info(o.default.stringify(s.conf));let c=s.createRegistry(n),l=s.fullPackageName,u=c.constructNewPackage(l);for(let[e,t]of Object.entries(s.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(s.conf.meta),await u.finish(),t.refresh&&await c.updateIfNeeded()}),n}function kr(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 a.ConsoleLoggerAdapter,o=t.length>0?t:[`.`],s=n.default.join(e,`src`,`structure`,`templates`),c=!1;for(let e of o){let t=await vr({blockPath:e,isSdkInternal:!!r.sdkInternal,updateDepsOnly:!1,mode:`check`,templatesRoot:s,log:e=>i.info(e)});i.info(yr(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`],Ar=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 jr(e,t,n,r){if(e!==void 0&&e!==``)return e;if(n)throw new Ar(t);return r()}async function Mr(e){let t=await jr(e.npmOrg,`npm-org`,e.nonInteractive,()=>(0,l.input)({message:`npm org (e.g. @platforma-open):`,default:`@platforma-open`})),n=await jr(e.orgScope,`org-scope`,e.nonInteractive,()=>(0,l.input)({message:`org scope (e.g. my-org):`})),r=await jr(e.shortName,`short-name`,e.nonInteractive,()=>(0,l.input)({message:`block short name (e.g. mixcr-clonotyping):`})),i;i=e.withSoftware===void 0?e.nonInteractive?!1:await(0,l.confirm)({message:`Include a software module?`,default:!1}):e.withSoftware;let a;if(i){if(a=await jr(e.platform,`platform`,e.nonInteractive,()=>(0,l.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 Nr(e){let t=e.vars,n=Yt(t),r=new se(e.blockPath),i=new ce(e.templatesRoot),a=Xt({blockVars:t,modules:n,isSdkInternal:!1,version:2,dryRun:!1}),o=Z.filter(vn),s,c;try{s=await yn(o),c=await xn(Tn)}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 Bt(gr,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 Pr(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 a.ConsoleLoggerAdapter,o=r.withSoftware===!0,s=r.software===!1;if(o&&s)throw Error(`--with-software and --no-software are mutually exclusive.`);let c=o?!0:s?!1:void 0,l=await Mr({npmOrg:r.npmOrg,orgScope:r.orgScope,shortName:r.shortName,withSoftware:c,platform:r.platform,nonInteractive:r.nonInteractive});await Nr({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 Fr=[`dev`,`release`],Ir=[`docker`,`binary`,`all`,`none`],Lr=[`local`,`remote`];function Rr(e){if(e.usePublished){if(e.variant===`docker`||e.variant===`all`)throw u.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 zr=`public.ecr.aws`,Br=`us-east-1`;function Vr(e){if(process.env.AWS_ACCESS_KEY_ID||process.env.AWS_PROFILE)return;let t=process.env.PL_AWS_PROFILE??u.defaults.AWS_DEV_PROFILE;process.env.AWS_PROFILE=t,e?.debug(`Using AWS profile '${t}' for dev push credentials`)}function Hr(e){return new URL(`https://${e}`).hostname}function Ur(){return` aws sso login --profile ${process.env.AWS_PROFILE??process.env.PL_AWS_PROFILE??u.defaults.AWS_DEV_PROFILE}`}async function Wr(e,t){let n=Hr(e);if(n!==zr)throw u.util.CLIError(`automatic docker login is only supported for '${zr}', 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:Br}).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 u.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`+Ur())}let a=(0,d.spawnSync)(`docker`,[`login`,`--username`,r,`--password-stdin`,n],{input:i,stdio:[`pipe`,`inherit`,`inherit`],env:{...process.env,HOME:process.env.HOME||c.homedir()}});if(a.error||a.status!==0)throw u.util.CLIError(`'docker login ${n}' failed`)}async function Gr(e){let{core:t,scenario:n,options:r={},logger:i}=e,a=r.ids;t.buildMode=Kr(n);let o=()=>t.buildSoftwareArchives({ids:a,forceBuild:!!r.force,contentRoot:r.contentRoot,skipIfEmpty:!a,condaBuild:r.condaBuild});switch(n.kind){case`binary-existing`:t.writePublishedArtifactInfo({ids:a});break;case`no-software`:break;case`bare`:r.buildDocker&&t.buildDockerImages({ids:a,registry:r.dockerRegistry,strictPlatformMatching:u.envs.isCI()}),await o(),r.pushDocker&&t.publishDockerImages({ids:a,pushTo:r.dockerPushTo,strictPlatformMatching:u.envs.isCI()});break;case`target`:{let{channel:e,variant:s,location:c}=n,l=s!==`binary`,d=s!==`docker`,f=c===`remote`,p=Yr(e,r);l&&t.buildDockerImages({ids:a,registry:p.pull,strictPlatformMatching:u.envs.isCI()}),d&&await o(),f&&e===`dev`&&(l||d)&&Vr(i),l&&f&&(p.autoLogin&&p.push&&await Wr(p.push,i),t.publishDockerImages({ids:a,pushTo:p.push,strictPlatformMatching:u.envs.isCI()})),d&&f&&await t.publishPackages({ids:a,storageURL:r.storageUrl});break}default:u.util.assertNever(n)}t.buildSwJsonFiles({packageIds:a,noSoftware:n.kind===`no-software`})}function Kr(e){return e.kind!==`target`||e.channel===`release`?`release`:e.variant!==`docker`&&e.location===`remote`?`dev-remote`:`dev-local`}function qr(e){if(!e.includes(`://`))return e;let t=new URL(e);return t.host+t.pathname}function Jr(e){return{registry:qr(e),autoLogin:e.startsWith(`ecr://`)}}function Yr(e,t){let n=e===`dev`,r=process.env[n?u.envs.PL_DEV_DOCKER_PUSH_URL:u.envs.PL_RELEASE_DOCKER_PUSH_URL],i=process.env[n?u.envs.PL_DEV_DOCKER_PULL_URL:u.envs.PL_RELEASE_DOCKER_PULL_URL],a=t.dockerPushTo??r??(n?u.defaults.DEV_DOCKER_PUSH_TARGET:void 0),o=a?Jr(a):{registry:void 0,autoLogin:!1},s=t.dockerRegistry??i??a;return{pull:s?qr(s):void 0,push:o.registry,autoLogin:o.autoLogin}}var Xr=`PL_BUILD_CHANNEL`,Zr=`PL_BUILD_VARIANT`,Qr=`PL_BUILD_LOCATION`,$r=`PL_BUILD_USE_PUBLISHED`;u.envs.PL_DOCKER_REGISTRY_PUSH_TO,u.envs.PL_DEV_DOCKER_PUSH_URL,u.envs.PL_DEV_DOCKER_PULL_URL,u.envs.PL_DEV_BINARY_UPLOAD_URL,u.envs.PL_RELEASE_DOCKER_PUSH_URL,u.envs.PL_RELEASE_DOCKER_PULL_URL,u.envs.PL_RELEASE_BINARY_UPLOAD_URL;function ei(){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([...Fr]).env(Xr)),e.addOption(new t.Option(`--variant <variant>`,`artifact kind to build (default: all declared)`).choices([...Ir]).env(Zr)),e.addOption(new t.Option(`--location <location>`,`where the artifact lands (local = no push)`).choices([...Lr]).env(Qr)),e.addOption(new t.Option(`--use-published`,`do not build or push; emit a descriptor pointing at the already-published release artifact`).env($r)),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([...u.util.AllPlatforms]).env(u.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(u.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(u.envs.PL_PKG_CONTENT_ROOT)),e.addOption(new t.Option(`--storage-url <url>`,`override binary upload registry URL`).env(u.envs.PL_PKG_STORAGE_URL)),e.addOption(new t.Option(`--docker-registry <registry>`,`docker pull registry embedded in the descriptor`).env(u.envs.PL_DOCKER_REGISTRY)),e.addOption(new t.Option(`--docker-push-to <registry>`,`alternative registry for docker push`).env(u.envs.PL_DOCKER_REGISTRY_PUSH_TO)),e.addOption(new t.Option(`--docker-build`,`build docker images`).env(u.envs.PL_DOCKER_BUILD).default(!1)),e.addOption(new t.Option(`--docker-no-build`,`do not build docker images`).env(u.envs.PL_DOCKER_NO_BUILD).default(!1)),e.addOption(new t.Option(`--docker-autopush`,`push docker images after build`).env(u.envs.PL_DOCKER_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--docker-no-autopush`,`do not push docker images`).env(u.envs.PL_DOCKER_NO_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--conda-build`,`build conda environment before packing`).env(u.envs.PL_CONDA_BUILD).default(!1)),e.addOption(new t.Option(`--conda-no-build`,`do not build conda environment`).env(u.envs.PL_CONDA_NO_BUILD).default(!1)),e.action(async e=>{let t=u.util.createLogger(e.logLevel);try{let n=Rr({channel:e.channel,variant:e.variant,location:e.location,usePublished:!!e.usePublished}),r=(0,u.createBuilder)(t,{packageRoot:e.packageRoot});r.version=e.version,r.targetPlatform=e.platform,r.allPlatforms=!!e.allPlatforms,r.fullDirHash=!!e.fullDirHash;let i=u.util.shouldDoAction({default:u.envs.isCI(),enable:e.dockerBuild,disable:e.dockerNoBuild}),a=i&&u.util.shouldDoAction({default:u.envs.isCI()&&!r.isPrivate,enable:e.dockerAutopush,disable:e.dockerNoAutopush});await Gr({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:a,condaBuild:u.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 ti(){let e=new t.Command(`software`).description(`Build and publish a block's software modules`);return e.addCommand(ei()),e}function ni(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(ie()),n.addCommand(ae()),n.addCommand(oe()),n.addCommand(Sr(e)),n.addCommand(Cr()),n.addCommand(wr()),n.addCommand(Or()),n.addCommand(ti());let r=new t.Command(`structure`).description(`Manage block scaffolding against the canonical structure (check / init / refresh)`);return r.addCommand(kr(e)),r.addCommand(Pr(e)),r.addCommand(xr(e)),n.addCommand(r),n}async function ri(e,t){await ni(t).parseAsync(e)}exports.buildProgram=ni,exports.run=ri;
|
|
20
|
+
`,vr=`# No dependencies specified for this script
|
|
21
|
+
`;function yr(){_(`software`,()=>{C(`src/main.py`,je(_r)),C(`src/requirements.txt`,je(vr)),x(`package.json`,D(e=>hr(e)),()=>{gr()})})}function br(){_(`model`,()=>{w(`eslint.config.mjs`),w(`vite.config.mts`)}),_(`ui`,()=>{w(`eslint.config.mjs`),w(`vite.config.ts`),w(`tsconfig.app.json`),w(`tsconfig.node.json`)}),_(`test`,()=>{w(`eslint.config.mjs`)}),_(`root`,()=>{w(`.prettierrc`),x(`package.json`,D(()=>cn()),()=>{L(`pretty`),V(`@platforma-sdk/blocks-deps-updater`)})})}function xr(){ke(()=>{_(`root`,()=>{v(({ctx:e})=>!e.isSdkInternal,()=>{x(`pnpm-workspace.yaml`,D(e=>Pn(e)),e=>{for(let e of Z)_t(e);for(let e of jn)vt(e.entry,{of:e.of,ofVersion:e.ofVersion});for(let[e,t]of Object.entries(An))gt(e,t);e.modules.some(e=>e.scope===`software`)&>(Mn,Nn)})})})})}var Sr=Se(()=>{Rn(),Bn(),$n(),nr(),ar(),cr(),dr(),yr(),br(),xr()});async function Cr(){return Tn(Z.filter(wn))}async function wr(e){let t=n.default.resolve(e.blockPath),r=e.mode===`check`,i=new se(t),a=new ce(e.templatesRoot),o=Vt(Sr,i,an({fs:i,isSdkInternal:e.isSdkInternal,updateDepsOnly:e.updateDepsOnly,dryRun:r}),{templates:a,registryLookup:e.updateDepsOnly?await Cr():void 0,derivedPinLookup:e.updateDepsOnly?await Dn(jn):void 0,rediscover:()=>an({fs:i,isSdkInternal:e.isSdkInternal,updateDepsOnly:!1,dryRun:!0})});return{blockPath:e.blockPath,changes:o.changes}}function Tr(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(`
|
|
22
|
+
`)}`}async function Er(e){for(let t of e.paths){let n=await wr({blockPath:t,isSdkInternal:e.isSdkInternal,updateDepsOnly:e.updateDepsOnly,mode:`refresh`,templatesRoot:e.templatesRoot,log:t=>e.logger.info(t)});e.logger.info(Tr(t,n.changes))}}function Dr(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?t:[`.`],o=n.default.join(e,`src`,`structure`,`templates`);await Er({paths:i,isSdkInternal:!!r.sdkInternal,updateDepsOnly:!!r.updateDepsOnly,templatesRoot:o,logger:new a.ConsoleLoggerAdapter})}),r}function Or(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 a.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 Er({paths:[`.`],isSdkInternal:!1,updateDepsOnly:!0,templatesRoot:n.default.join(e,`src`,`structure`,`templates`),logger:t})}),r}function kr(){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 a.ConsoleLoggerAdapter,r=await new e.b(e._(t.registry),n).listGlobalOverviewSnapshots();if(t.json)n.info(JSON.stringify(r,null,2));else if(r.length===0)n.info(`No snapshots found.`);else{n.info(`Found ${r.length} snapshot(s):\n`);for(let e of r)n.info(` ${e.timestamp}`),n.info(` Path: ${e.path}`),n.info(``)}}),n}function Ar(){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 a.ConsoleLoggerAdapter,r=new e.b(e._(t.registry),n),i=await r.listGlobalOverviewSnapshots();if(!i.find(e=>e.timestamp===t.snapshot))throw Error(`Snapshot '${t.snapshot}' not found. Available snapshots:\n${i.map(e=>` - ${e.timestamp}`).join(`
|
|
23
|
+
`)||` (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 r.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 jr(e){let t=e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);if(t){let{src:e,destName:n}=t.groups;return{src:e,destName:n}}else return{src:e,destName:n.default.basename(e)}}function Mr(e,n){return new t.Option(e,n).argParser((e,t)=>[...t??[],jr(e)]).default([])}var Nr=[`registry`,`organization`,`package`,`version`];function Pr(){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(Mr(`-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 a.ConsoleLoggerAdapter,i=e.p.parse({});for(let e of Nr)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=o.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 s=await e.n(i);n.info(o.default.stringify(s.conf));let c=s.createRegistry(n),l=s.fullPackageName,u=c.constructNewPackage(l);for(let[e,t]of Object.entries(s.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(s.conf.meta),await u.finish(),t.refresh&&await c.updateIfNeeded()}),n}function Fr(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 a.ConsoleLoggerAdapter,o=t.length>0?t:[`.`],s=n.default.join(e,`src`,`structure`,`templates`),c=!1;for(let e of o){let t=await wr({blockPath:e,isSdkInternal:!!r.sdkInternal,updateDepsOnly:!1,mode:`check`,templatesRoot:s,log:e=>i.info(e)});i.info(Tr(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`],Ir=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 Lr(e,t,n,r){if(e!==void 0&&e!==``)return e;if(n)throw new Ir(t);return r()}async function Rr(e){let t=await Lr(e.npmOrg,`npm-org`,e.nonInteractive,()=>(0,l.input)({message:`npm org (e.g. @platforma-open):`,default:`@platforma-open`})),n=await Lr(e.orgScope,`org-scope`,e.nonInteractive,()=>(0,l.input)({message:`org scope (e.g. my-org):`})),r=await Lr(e.shortName,`short-name`,e.nonInteractive,()=>(0,l.input)({message:`block short name (e.g. mixcr-clonotyping):`})),i;i=e.withSoftware===void 0?e.nonInteractive?!1:await(0,l.confirm)({message:`Include a software module?`,default:!1}):e.withSoftware;let a;if(i){if(a=await Lr(e.platform,`platform`,e.nonInteractive,()=>(0,l.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 zr(e){let t=e.vars,n=Xt(t),r=new se(e.blockPath),i=new ce(e.templatesRoot),a=Zt({blockVars:t,modules:n,isSdkInternal:!1,version:2,dryRun:!1}),o=Z.filter(wn),s,c;try{s=await Tn(o),c=await Dn(jn)}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 Vt(Sr,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 Br(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 a.ConsoleLoggerAdapter,o=r.withSoftware===!0,s=r.software===!1;if(o&&s)throw Error(`--with-software and --no-software are mutually exclusive.`);let c=o?!0:s?!1:void 0,l=await Rr({npmOrg:r.npmOrg,orgScope:r.orgScope,shortName:r.shortName,withSoftware:c,platform:r.platform,nonInteractive:r.nonInteractive});await zr({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 Vr=[`dev`,`release`],Hr=[`docker`,`binary`,`all`,`none`],Ur=[`local`,`remote`];function Wr(e){if(e.usePublished){if(e.variant===`docker`||e.variant===`all`)throw u.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 Gr=`public.ecr.aws`,Kr=`us-east-1`;function qr(e){if(process.env.AWS_ACCESS_KEY_ID||process.env.AWS_PROFILE)return;let t=process.env.PL_AWS_PROFILE??u.defaults.AWS_DEV_PROFILE;process.env.AWS_PROFILE=t,e?.debug(`Using AWS profile '${t}' for dev push credentials`)}function Jr(e){return new URL(`https://${e}`).hostname}function Yr(){return` aws sso login --profile ${process.env.AWS_PROFILE??process.env.PL_AWS_PROFILE??u.defaults.AWS_DEV_PROFILE}`}async function Xr(e,t){let n=Jr(e);if(n!==Gr)throw u.util.CLIError(`automatic docker login is only supported for '${Gr}', 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:Kr}).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 u.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`+Yr())}let a=(0,d.spawnSync)(`docker`,[`login`,`--username`,r,`--password-stdin`,n],{input:i,stdio:[`pipe`,`inherit`,`inherit`],env:{...process.env,HOME:process.env.HOME||c.homedir()}});if(a.error||a.status!==0)throw u.util.CLIError(`'docker login ${n}' failed`)}async function Zr(e){let{core:t,scenario:n,options:r={},logger:i}=e,a=r.ids;t.buildMode=Qr(n);let o=()=>t.buildSoftwareArchives({ids:a,forceBuild:!!r.force,contentRoot:r.contentRoot,skipIfEmpty:!a,condaBuild:r.condaBuild});switch(n.kind){case`binary-existing`:t.writePublishedArtifactInfo({ids:a});break;case`no-software`:break;case`bare`:r.buildDocker&&t.buildDockerImages({ids:a,registry:r.dockerRegistry,strictPlatformMatching:u.envs.isCI()}),await o(),r.pushDocker&&t.publishDockerImages({ids:a,pushTo:r.dockerPushTo,strictPlatformMatching:u.envs.isCI()});break;case`target`:{let{channel:e,variant:s,location:c}=n,l=s!==`binary`,d=s!==`docker`,f=c===`remote`,p=ti(e,r);l&&t.buildDockerImages({ids:a,registry:p.pull,strictPlatformMatching:u.envs.isCI()}),d&&await o(),f&&e===`dev`&&(l||d)&&qr(i),l&&f&&(p.autoLogin&&p.push&&await Xr(p.push,i),t.publishDockerImages({ids:a,pushTo:p.push,strictPlatformMatching:u.envs.isCI()})),d&&f&&await t.publishPackages({ids:a,storageURL:r.storageUrl});break}default:u.util.assertNever(n)}t.buildSwJsonFiles({packageIds:a,noSoftware:n.kind===`no-software`})}function Qr(e){return e.kind!==`target`||e.channel===`release`?`release`:e.variant!==`docker`&&e.location===`remote`?`dev-remote`:`dev-local`}function $r(e){if(!e.includes(`://`))return e;let t=new URL(e);return t.host+t.pathname}function ei(e){return{registry:$r(e),autoLogin:e.startsWith(`ecr://`)}}function ti(e,t){let n=e===`dev`,r=process.env[n?u.envs.PL_DEV_DOCKER_PUSH_URL:u.envs.PL_RELEASE_DOCKER_PUSH_URL],i=process.env[n?u.envs.PL_DEV_DOCKER_PULL_URL:u.envs.PL_RELEASE_DOCKER_PULL_URL],a=t.dockerPushTo??r??(n?u.defaults.DEV_DOCKER_PUSH_TARGET:void 0),o=a?ei(a):{registry:void 0,autoLogin:!1},s=t.dockerRegistry??i??a;return{pull:s?$r(s):void 0,push:o.registry,autoLogin:o.autoLogin}}var ni=`PL_BUILD_CHANNEL`,ri=`PL_BUILD_VARIANT`,ii=`PL_BUILD_LOCATION`,ai=`PL_BUILD_USE_PUBLISHED`;u.envs.PL_DOCKER_REGISTRY_PUSH_TO,u.envs.PL_DEV_DOCKER_PUSH_URL,u.envs.PL_DEV_DOCKER_PULL_URL,u.envs.PL_DEV_BINARY_UPLOAD_URL,u.envs.PL_RELEASE_DOCKER_PUSH_URL,u.envs.PL_RELEASE_DOCKER_PULL_URL,u.envs.PL_RELEASE_BINARY_UPLOAD_URL;function oi(){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([...Vr]).env(ni)),e.addOption(new t.Option(`--variant <variant>`,`artifact kind to build (default: all declared)`).choices([...Hr]).env(ri)),e.addOption(new t.Option(`--location <location>`,`where the artifact lands (local = no push)`).choices([...Ur]).env(ii)),e.addOption(new t.Option(`--use-published`,`do not build or push; emit a descriptor pointing at the already-published release artifact`).env(ai)),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([...u.util.AllPlatforms]).env(u.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(u.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(u.envs.PL_PKG_CONTENT_ROOT)),e.addOption(new t.Option(`--storage-url <url>`,`override binary upload registry URL`).env(u.envs.PL_PKG_STORAGE_URL)),e.addOption(new t.Option(`--docker-registry <registry>`,`docker pull registry embedded in the descriptor`).env(u.envs.PL_DOCKER_REGISTRY)),e.addOption(new t.Option(`--docker-push-to <registry>`,`alternative registry for docker push`).env(u.envs.PL_DOCKER_REGISTRY_PUSH_TO)),e.addOption(new t.Option(`--docker-build`,`build docker images`).env(u.envs.PL_DOCKER_BUILD).default(!1)),e.addOption(new t.Option(`--docker-no-build`,`do not build docker images`).env(u.envs.PL_DOCKER_NO_BUILD).default(!1)),e.addOption(new t.Option(`--docker-autopush`,`push docker images after build`).env(u.envs.PL_DOCKER_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--docker-no-autopush`,`do not push docker images`).env(u.envs.PL_DOCKER_NO_AUTOPUSH).default(!1)),e.addOption(new t.Option(`--conda-build`,`build conda environment before packing`).env(u.envs.PL_CONDA_BUILD).default(!1)),e.addOption(new t.Option(`--conda-no-build`,`do not build conda environment`).env(u.envs.PL_CONDA_NO_BUILD).default(!1)),e.action(async e=>{let t=u.util.createLogger(e.logLevel);try{let n=Wr({channel:e.channel,variant:e.variant,location:e.location,usePublished:!!e.usePublished}),r=(0,u.createBuilder)(t,{packageRoot:e.packageRoot});r.version=e.version,r.targetPlatform=e.platform,r.allPlatforms=!!e.allPlatforms,r.fullDirHash=!!e.fullDirHash;let i=u.util.shouldDoAction({default:u.envs.isCI(),enable:e.dockerBuild,disable:e.dockerNoBuild}),a=i&&u.util.shouldDoAction({default:u.envs.isCI()&&!r.isPrivate,enable:e.dockerAutopush,disable:e.dockerNoAutopush});await Zr({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:a,condaBuild:u.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 si(){let e=new t.Command(`software`).description(`Build and publish a block's software modules`);return e.addCommand(oi()),e}function ci(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(ie()),n.addCommand(ae()),n.addCommand(oe()),n.addCommand(Or(e)),n.addCommand(kr()),n.addCommand(Ar()),n.addCommand(Pr()),n.addCommand(si());let r=new t.Command(`structure`).description(`Manage block scaffolding against the canonical structure (check / init / refresh)`);return r.addCommand(Fr(e)),r.addCommand(Br(e)),r.addCommand(Dr(e)),n.addCommand(r),n}async function li(e,t){await ci(t).parseAsync(e)}exports.buildProgram=ci,exports.run=li;
|
|
24
24
|
//# sourceMappingURL=cli.js.map
|