@vef-framework-react/dev 2.31.0 → 2.32.0

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @vef-framework-react/dev v2.31.0 made by Venus | 2026-11-19T01:41:56.670Z */
1
+ /*! @vef-framework-react/dev v2.32.0 made by Venus | 2026-11-19T08:42:30.259Z */
2
2
  import dt from"chalk";import{program as y}from"commander";import R from"process";import b from"consola";import{randomBytes as de}from"crypto";import{constants as h}from"fs";import{chmod as fe,lstat as pe,mkdir as me,open as ge,readFile as le,rename as ue,unlink as ye}from"fs/promises";import{dirname as he,isAbsolute as A,relative as F,resolve as we}from"path";var c=class extends Error{constructor(t){super(t),this.name="CodeGenerationValidationError"}};import{existsSync as Q}from"fs";import{isAbsolute as P,relative as X,resolve as _}from"path";import{createJiti as Z}from"jiti";var ee=["code-generation.config.ts","code-generation.config.mts","code-generation.config.js","code-generation.config.mjs"];async function O({projectDir:e,configFile:t}){let n=t?[te(e,t)]:ee.map(s=>_(e,s)),o=n.find(s=>Q(s));if(!o)throw new c(`Code generation config not found. Looked for: ${n.join(", ")}`);let a=await Z(e).import(o),r=ne(a);return oe(r,o),{config:r,configPath:o}}function te(e,t){let n=P(t)?t:_(e,t),o=X(e,n);if(o.startsWith("..")||P(o))throw new c(`Code generation config file escapes project root: ${t}. Must stay within ${e}.`);return n}function ne(e){return e!==null&&typeof e=="object"&&"default"in e&&e.default!==null&&typeof e.default=="object"?e.default:e}function oe(e,t){if(typeof e!="object"||e===null)throw new c(`Code generation config at ${t} must export a CodeGenerationConfig object.`);e.codeSetKeys!==void 0&&ie(e.codeSetKeys,t)}function ie(e,t){if(typeof e!="object"||e===null)throw new c(`Code generation config at ${t} field \`codeSetKeys\` must be an object when set.`);if(typeof e.fetchCodeSetKeys!="function")throw new c(`Code generation config at ${t} field \`codeSetKeys.fetchCodeSetKeys\` must be a function.`);if(e.output!==void 0&&typeof e.output!="string")throw new c(`Code generation config at ${t} field \`codeSetKeys.output\` must be a string when set; got ${typeof e.output}.`);if(e.timeout!==void 0&&!re(e.timeout))throw new c(`Code generation config at ${t} field \`codeSetKeys.timeout\` must be a finite non-negative number when set; got ${String(e.timeout)}.`)}function re(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var se="@vef-framework-react/hooks",ae=["/* eslint-disable */","// @ts-nocheck","// noinspection JSUnusedGlobalSymbols","// AUTO-GENERATED by @vef-framework-react/dev (vef gen:code-set-keys). DO NOT EDIT."];function T(e,t){let{configFile:n,augmentTarget:o=se}=t,i=[...ae,`// Source: ${n}`,""];if(e.length===0)i.push("export type CodeSetKey = never;");else{i.push("export type CodeSetKey =");for(let[a,r]of e.entries()){let s=a===e.length-1?";":"";r.comment&&i.push(` /** ${ce(r.comment)} */`),i.push(` | ${JSON.stringify(r.key)}${s}`)}}return i.push("",`declare module ${JSON.stringify(o)} {`," interface Register {"," codeSetKeys: CodeSetKey;"," }","}",""),i.join(`
3
3
  `)}function ce(e){return e.replaceAll(/\s+/g," ").trim().replaceAll("*/",String.raw`*\/`)}var Ce="src/types/code-set-keys.gen.ts",Se=3e4,G=/^[\w.-]+$/,Ee="letters, digits, underscore, dot, hyphen",ve=e=>console.warn(e);function ke(e,t){return e.key<t.key?-1:e.key>t.key?1:0}async function S({projectDir:e,configFile:t,output:n,check:o=!1,augmentTarget:i,onWarn:a=ve}){let{config:r,configPath:s}=await O({projectDir:e,configFile:t});if(!r.codeSetKeys)throw new c(`Code generation config at ${s} has no \`codeSetKeys\` block.`);let{codeSetKeys:p}=r,m=await xe(p.fetchCodeSetKeys,p.timeout??Se);Ke(m);let d=Pe(m,a);d.length===0&&a("`fetchCodeSetKeys` returned no entries; the generated file will declare `CodeSetKey = never`.");let g=_e(e,n??p.output??Ce),x=T(d,{configFile:F(e,s),augmentTarget:i}),K=await Te(g)!==x;return K&&!o&&(await Oe(g),await Ae(g,x)),{outputPath:g,keyCount:d.length,changed:K}}async function xe(e,t){if(t<=0)return await e();let n;try{return await Promise.race([e(),new Promise((o,i)=>{n=setTimeout(()=>i(new Error(`fetchCodeSetKeys timed out after ${t}ms.`)),t)})])}finally{n&&clearTimeout(n)}}function Ke(e){for(let t of e)if(typeof t.key!="string"||!G.test(t.key))throw new c(`Invalid code set key ${JSON.stringify(t.key)}. Keys must match ${G} (${Ee}).`)}function Pe(e,t){let n=new Map;for(let o of e){let i=n.get(o.key);if(!i){n.set(o.key,o);continue}i.comment!==o.comment&&t(`Duplicate code set key "${o.key}" with conflicting comments; keeping the first occurrence.`)}return n.values().toArray().toSorted(ke)}function _e(e,t){if(A(t))throw new c(`Output path must be relative to project root; absolute paths are rejected: ${t}`);let n=we(e,t),o=F(e,n);if(o.startsWith("..")||A(o))throw new c(`Output path escapes project root: ${t}. Must stay within ${e}.`);return n}async function Oe(e){let t;try{t=await pe(e)}catch(n){if(n.code==="ENOENT")return;throw n}if(t.isSymbolicLink())throw new c(`Refusing to overwrite symlink at output path: ${e}. Delete the symlink and rerun generation if this is intentional.`)}async function Te(e){try{return await le(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}async function Ae(e,t){await me(he(e),{recursive:!0});let n=de(6).toString("hex"),o=`${e}.${n}.tmp`,i=h.O_NOFOLLOW??0,a=h.O_WRONLY|h.O_CREAT|h.O_EXCL|i,r=await ge(o,a,384);try{await r.writeFile(t,"utf-8")}finally{await r.close()}try{await ue(o,e)}catch(s){throw await ye(o).catch(()=>{}),s}await fe(e,420)}import{resolve as Ge}from"path";import{exit as Fe}from"process";import $ from"consola";import{execa as $e}from"execa";import Ne from"fs-extra";var{readJsonSync:Re}=Ne,f=class extends Error{};function w(){let e=Ge(import.meta.dirname,"../../package.json");return Re(e,{encoding:"utf-8"}).version}function N(e){e instanceof f?$.error(e.message):$.error(e),Fe(1)}async function C(){try{await $e("pnpm",["--version"])}catch{throw new f("VEF requires pnpm. Install it from https://pnpm.io and try again.")}}async function j(e,t=R.cwd()){try{let n=await S({projectDir:t,configFile:e.config,output:e.output,check:e.check,onWarn:i=>b.warn(i)});if(e.check&&n.changed)throw new f(`Generated code set keys file is stale at ${n.outputPath}. Run \`vef gen:code-set-keys\` to refresh.`);let o=n.changed?"":" (unchanged)";b.success(`Generated ${n.keyCount} code set keys -> ${n.outputPath}${o}`)}catch(n){if(n instanceof f)throw n;if(R.env.CI){let o=n instanceof Error?n.message:String(n);throw new f(`gen:code-set-keys failed: ${o}`)}throw n}}import{resolve as l}from"path";import be,{exit as je}from"process";import u from"consola";import{execa as v}from"execa";import Ie from"fs-extra";import H from"ora";import Ue from"prompts";var I={"pre-commit":"pnpm dlx lint-staged","commit-msg":"pnpm dlx commitlint --edit $1","pre-push":"pnpm typecheck && pnpm test"},U={"*.{js,ts,tsx,json,jsonc,md,mdx,html}":"eslint --fix","*.{css,scss}":"stylelint --fix"},L={prepare:"vef prepare",typecheck:"tsc --noEmit",test:"vitest run --passWithNoTests"},J="@vef-framework-react/";var{copy:Le,exists:Je,move:De,readdir:Ve,readFile:D,readJson:We,writeFile:V,writeJson:Me}=Ie,W="http://127.0.0.1:8080";function He(e){return e.trim().toLowerCase().replaceAll(/\s+/g,"-").replace(/^[._]+/,"").replaceAll(/[^a-z0-9~-]+/g,"-").replaceAll(/^-+|-+$/g,"")}function M(e){let t=typeof e=="string"?e.trim():"";return t?/[/\\]/.test(t)||t.includes("..")?"App name cannot contain path separators or '..'":!0:"App name is required"}function ze(e,t){for(let n of["dependencies","devDependencies"]){let o=e[n];if(o)for(let i of Object.keys(o))i.startsWith(J)&&(o[i]=t)}}function E(e,t,n){return e.replace(new RegExp(`^${t}=.*$`,"m"),()=>`${t}=${n}`)}async function z(e={},t=be.cwd()){u.start("Creating a new VEF project");let n=[];e.name===void 0&&n.push({type:"text",name:"name",message:"What is the name of your app?",validate:M}),e.title===void 0&&n.push({type:"text",name:"title",message:"What is the title of your app?",validate:g=>typeof g=="string"&&g.trim().length>0||"App title is required"}),e.apiUrl===void 0&&n.push({type:"text",name:"apiUrl",message:"Dev API base URL?",initial:W});let o=await Ue(n,{onCancel:()=>{u.info("Operation cancelled"),je(0)}}),i=e.name??o.name,a=M(i);if(a!==!0)throw new f(a);let r=i.trim(),s=He(r),p=(e.title??o.title)?.trim()||r,m=(e.apiUrl??o.apiUrl)?.trim()||W,d=l(t,r);if(await Je(d)&&(await Ve(d)).length>0)throw new f(`Target directory "${r}" already exists and is not empty. Choose another name or empty it first.`);await C(),await qe(d),await Be(s,d),await Qe(d,{packageName:s,appTitle:p,apiUrl:m}),await Xe(d),await Ze(d),et(r)}var Ye=[["_gitignore",".gitignore"],["_gitattributes",".gitattributes"],["_editorconfig",".editorconfig"],["_package.json","package.json"],["_tsconfig.json","tsconfig.json"],["_eslint.config.ts","eslint.config.ts"],["_stylelint.config.js","stylelint.config.js"],["_commitlint.config.ts","commitlint.config.ts"],["_vite.config.ts","vite.config.ts"]];async function qe(e){let t=l(import.meta.dirname,"../template");await Le(t,e),u.success("Successfully copied template files");for(let[n,o]of Ye)await De(l(e,n),l(e,o))}async function Be(e,t){let n=l(t,"package.json"),o=await We(n,{encoding:"utf-8"}),i=w();o.name=e,ze(o,i),await Me(n,o,{encoding:"utf-8",spaces:2}),u.success(`Successfully set the app name and pinned framework packages to v${i}`)}async function Qe(e,t){let n=l(e,"env/.env"),o=await D(n,{encoding:"utf-8"}),i=E(E(o,"VEF_APP_NAME",t.packageName),"VEF_APP_TITLE",t.appTitle);await V(n,i);let a=l(e,"env/.env.development"),r=await D(a,{encoding:"utf-8"});await V(a,E(r,"VEF_APP_API_BASE_URL",t.apiUrl)),u.success("Successfully configured environment files")}async function Xe(e){let t=H("Initializing git repository...").start();try{await v`git --version`,await v({cwd:e})`git init`,t.succeed("Successfully initialized git repository")}catch(n){throw t.fail("Failed to initialize git repository"),n}}async function Ze(e){let t=H("Installing dependencies...").start();try{await v({cwd:e})("pnpm",["install"]),t.succeed("Successfully installed dependencies")}catch(n){throw t.fail("Failed to install dependencies"),n}}function et(e){u.success("VEF project created successfully!"),u.box(`Next steps:
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vef-framework-react/dev",
3
- "version": "2.31.0",
3
+ "version": "2.32.0",
4
4
  "private": false,
5
5
  "description": "Dev tools for VEF framework",
6
6
  "keywords": [
@@ -10,6 +10,11 @@
10
10
  "dev"
11
11
  ],
12
12
  "homepage": "https://vef.ilxqx.com",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/coldsmirk/vef-framework-react.git",
16
+ "directory": "packages/dev"
17
+ },
13
18
  "license": "Apache-2.0",
14
19
  "author": {
15
20
  "name": "Venus",