@funish/basis 0.2.6 → 0.2.8-edge.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.
@@ -0,0 +1 @@
1
+ import{T as e}from"./vendor/common-DNe_sHJp.mjs";export{e as parseYAML};
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import{r as e}from"../_chunks/rolldown-runtime-coR7_hWt.mjs";import{C as t,S as n,_ as r,a as i,c as a,d as o,f as s,g as c,h as l,k as u,l as d,m as f,o as p,p as m,s as h,u as g,v as _,x as v,y}from"../_chunks/vendor/common-DNe_sHJp.mjs";import{n as b}from"../_chunks/config-Coiy-SOC.mjs";import"../_chunks/run-CYtHqbev.mjs";import{t as x}from"../_chunks/lint-ESN87Ohj.mjs";import{t as S}from"../_chunks/fmt-C7X2ZSv6.mjs";import{existsSync as C}from"node:fs";import{readFile as w,stat as ee,writeFile as T}from"node:fs/promises";import{execSync as E,spawnSync as D}from"node:child_process";var O=f();async function te(e=process.cwd(),t={}){let{force:n=!1,skipGitCheck:r=!1}=t;l.start(`Initializing basis configuration`);let i=(await y({cwd:e,name:`basis`}))._configFile;if(i&&!n)return l.error(`Configuration file already exists: ${i}`),l.info(`Use --force to overwrite.`),!1;let a=(await g(e))?.name||`npm`,o=a===`npm`?`npx`:a,s={git:{hooks:{"pre-commit":`${o} basis git staged`,"commit-msg":`${o} basis git lint-commit`},staged:{rules:{"**/*.{ts,tsx,js,jsx}":`basis lint`,"**/*.{json,md,yml,yaml}":`basis fmt`}}}},c=`import { defineBasisConfig } from "@funish/basis/config";
3
+
4
+ export default defineBasisConfig(${JSON.stringify(s,null,2)});
5
+ `,u=`${e}/basis.config.ts`;if(await T(u,c,`utf8`),l.success(`Configuration created in ${u}`),!r)try{await(0,O.exec)([`--version`],e),l.info(`Git detected`)}catch{l.info(`Git not found`)}return l.success(`Basis initialization completed!`),l.info(`Run 'basis git setup' to setup Git hooks`),!0}const k=c({meta:{name:`init`,description:`Initialize configuration`},args:{force:{type:`boolean`,description:`Overwrite existing configuration`},"skip-git-check":{type:`boolean`,description:`Skip git directory check`},"skip-install":{type:`boolean`,description:`Skip dependency installation`}},async run({args:e}){try{await te(process.cwd(),{force:e.force,skipGitCheck:e[`skip-git-check`],skipInstall:e[`skip-install`]})}catch(e){l.error(`Init failed:`,e),process.exit(1)}}}),A=await _(import.meta.url,{alias:{"@funish/build":`E:/basis/packages/build`,"./config":`E:/basis/packages/build/src/config`},transformOptions:{babel:{plugins:[]}}}).import(`E:/basis/packages/build/src/index.ts`),j=A.build;A.defineBuildConfig,A.fmtPath,A.analyzeDir,A.distSize,A.sideEffectSize,A.rolldownBuild,A.normalizeBundleInputs,A.transformDir,A.createJitiStub,A.SHEBANG_RE,A.shebangPlugin,A.hasShebang,A.makeExecutable;const M=c({meta:{name:`build`,description:`Build project`},args:{dir:{type:`string`,description:`Project directory`,default:`.`},stub:{type:`boolean`,description:`Generate stub files`,default:!1}},async run({args:e}){let t=u(e.dir||`.`);try{let{config:n={}}=await y({name:`isbuild`,configFile:`build.config`,cwd:t}),r=(n.entries||[]).map(t=>{if(typeof t==`string`){let[n,r]=t.split(`:`);return n.endsWith(`/`)?{type:`transform`,input:n,outDir:r,stub:e.stub}:{type:`bundle`,input:n.split(`,`),outDir:r,stub:e.stub}}return{...t,stub:e.stub}});(!r||r.length===0)&&(l.error(`No build entries specified in build.config.`),process.exit(1)),await j({cwd:t,...n,entries:r}),l.success(`Build completed`)}catch(e){l.error(`Build failed:`,e),process.exit(1)}}});var N=e(h());async function P(){try{let e=E(`git --exec-path`,{encoding:`utf8`}).trim();if(e){let t=(0,O.setupEnvironment)({LOCAL_GIT_DIRECTORY:u(e,`..`,`..`,`..`)});Object.assign(process.env,t.env),l.debug(`Using system Git from: ${t.gitLocation}`)}}catch{l.debug(`System Git not found, dugite will use embedded Git`)}}P();async function F(e){try{let t=(await(0,O.exec)([`diff`,`--cached`,`--name-only`],e)).stdout.trim().split(`
6
+ `).filter(Boolean),n=await(0,O.exec)([`diff`,`--cached`,`--name-only`,`--diff-filter=D`],e),r=new Set(n.stdout.trim().split(`
7
+ `).filter(Boolean));return t.filter(e=>!r.has(e))}catch{return[]}}async function I(e=process.cwd()){let{config:t}=await b(),n=t.git?.staged?.rules||{};if(Object.keys(n).length===0)return l.warn(`No staged rules configured. Add git.staged.rules to your basis.config.ts`),!0;let r=await F(e);if(r.length===0)return l.info(`No staged files to check`),!0;l.start(`Checking ${r.length} staged file(s)`);let i=!1,a=new Set;for(let[t,o]of Object.entries(n)){let n=(0,N.default)(t),s=r.filter(e=>!a.has(e)&&n(e));if(s.length!==0){l.info(`Running ${o} for ${s.length} file(s) matching ${t}`);try{let t=await(0,O.exec)([`status`,`--porcelain`],e),n=new Set;t.stdout.trim().split(`
8
+ `).filter(Boolean).forEach(e=>{let t=e.match(/^(..)\s+(.+)$/);if(!t)return;let[,r,i]=t;(r[1]===`M`||r===` M`)&&n.add(i)}),E(o,{cwd:e,stdio:`inherit`});let r=await(0,O.exec)([`status`,`--porcelain`],e),i=new Set;r.stdout.trim().split(`
9
+ `).filter(Boolean).forEach(e=>{let t=e.match(/^(..)\s+(.+)$/);if(!t)return;let[,r,a]=t;(r[1]===`M`||r===` M`)&&(s.includes(a)?i.add(a):n.has(a)||i.add(a))}),i.size>0&&(await(0,O.exec)([`add`,...Array.from(i)],e),l.info(`Re-staged ${i.size} file(s) after formatting`)),s.forEach(e=>a.add(e))}catch(e){i=!0,l.error(`Staged check failed for pattern '${t}':`,e)}}}return i?(l.error(`Some staged files checks failed`),!1):(l.success(`Staged files check passed`),!0)}const L=[`feat`,`fix`,`docs`,`style`,`refactor`,`perf`,`test`,`build`,`ci`,`chore`,`revert`];function R(e){let t=e.trim().split(`
10
+ `)[0],n=t.match(/^(\w+)(\(([^)]+)\))?(!)?:\s*(.+)$/);if(!n)return null;let[,r,,i,,a]=n;return{type:r,scope:i,subject:a,isBreaking:t.includes(`!`)||e.includes(`BREAKING CHANGE:`)}}async function z(e=process.cwd()){let{config:t}=await b(),n=t.git?.commitMsg,r=n?.types||L,i=n?.maxLength||72,a=n?.minLength||10,o=n?.scopeRequired||!1,s=n?.allowedScopes||[],c;try{let t=u(e,`.git/COMMIT_EDITMSG`);try{c=(await w(t)).toString(`utf8`)}catch{c=(await(0,O.exec)([`log`,`-1`,`--pretty=%B`],e)).stdout.trim()}}catch(e){return l.error(`Failed to read commit message:`,e),!1}let d=[],f=R(c);if(!f)return l.error(`Invalid commit format. Expected: type(scope): subject`),!1;r.includes(f.type)||d.push(`Invalid type '${f.type}'. Allowed: ${r.join(`, `)}`);let p=c.split(`
11
+ `)[0];return p.length>i&&d.push(`Header too long (${p.length} chars). Max: ${i}`),p.length<a&&d.push(`Header too short (${p.length} chars). Min: ${a}`),o&&!f.scope&&d.push(`Scope is required`),f.scope&&s.length>0&&!s.includes(f.scope)&&d.push(`Invalid scope '${f.scope}'. Allowed: ${s.join(`, `)}`),d.length>0?(l.error(`Invalid commit message:`),d.forEach(e=>l.error(` ${e}`)),!1):(l.success(`Commit message validation passed`),!0)}async function B(e=process.cwd()){let{config:t}=await b(),n=t.git?.hooks;if(!n||Object.keys(n).length===0)return l.warn(`No Git hooks configured`),!0;let r=u(e,`.git/hooks`);try{for(let[e,t]of Object.entries(n))await T(u(r,e),`#!/bin/sh\n${t}\n`,{mode:493}),l.success(`Created ${e} hook`);return!0}catch(e){return l.error(`Failed to setup Git hooks:`,e),!1}}async function V(e=process.cwd()){return l.start(`Setting up Git configuration`),await B(e)?(l.success(`Git setup completed`),!0):!1}const H=c({meta:{name:`git`,description:`Git operations`},async run({rawArgs:e}){let t=e[0];if(!t){l.info(`Available subcommands: staged, lint-commit, setup`),l.info(`Git passthrough mode: basis git <git-command>`);return}switch(t){case`staged`:await I()||process.exit(1);return;case`lint-commit`:await z()||process.exit(1);return;case`setup`:await V()||process.exit(1);return;default:try{let t=await(0,O.exec)(e,process.cwd(),{processCallback:e=>{e.stdout?.on(`data`,e=>{process.stdout.write(e)}),e.stderr?.on(`data`,e=>{process.stderr.write(e)})}});if(t.exitCode!==0)throw Error(`git exited with code ${t.exitCode}`)}catch(e){l.error(`Git operation failed:`,e),process.exit(1)}}}}),U=c({meta:{name:`run`,description:`Run scripts or files`},async run({rawArgs:e}){e.length===0&&(l.error(`Please specify a script name or file path`),process.exit(1));let[t,...n]=e,r=process.cwd(),{config:i}=await b(),a=i.run?.config,o=u(r,t);if(C(o))try{let t=_(r,a),n=t.esmResolve(o);process.argv=[process.argv[0],n,...e.slice(1)],await t.import(n);return}catch(e){l.error(`Failed to run file:`),l.error(` ${String(e)}`),process.exit(1)}try{await m(t,{cwd:r,args:n})}catch(e){l.error(`Failed to run script "${t}":`),l.error(` ${String(e)}`),process.exit(1)}}});var W=e(p());function G(e,t,n){if(t.version){if(W.default.valid(t.version))return t.version;throw Error(`Invalid version format: ${t.version}. Please use semantic versioning format (e.g., 1.0.0, 2.1.0-alpha.1)`)}if(!W.default.valid(e))throw Error(`Invalid current version format: ${e}. Please fix version in package.json to use semantic versioning format (e.g., 1.0.0)`);let r=W.default.prerelease(e),i=t.preid||(r&&typeof r[0]==`string`?r[0]:null)||n.preid||`edge`,a=`patch`;t.major?a=`major`:t.minor?a=`minor`:t.premajor?a=`premajor`:t.preminor?a=`preminor`:t.prepatch?a=`prepatch`:t.prerelease?a=r?`prerelease`:`prepatch`:t.fromGit&&(a=`patch`);let o=a===`prerelease`||a.startsWith(`pre`)?W.default.inc(e,a,i):W.default.inc(e,a);if(!o)throw Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return o}const K=c({meta:{name:`version`,description:`Update package version`},args:{version:{type:`positional`,description:`Version to set (patch, minor, major, prerelease, or specific version)`,required:!1},preid:{type:`string`,description:`Prerelease identifier (alpha, beta, rc)`},major:{type:`boolean`,description:`Bump major version`},minor:{type:`boolean`,description:`Bump minor version`},patch:{type:`boolean`,description:`Bump patch version`},premajor:{type:`boolean`,description:`Bump premajor version`},preminor:{type:`boolean`,description:`Bump preminor version`},prepatch:{type:`boolean`,description:`Bump prepatch version`},prerelease:{type:`boolean`,description:`Bump prerelease version`},"allow-same-version":{type:`boolean`,description:`Allow same version`}},async run({args:e}){try{let{config:r}=await b(),i={preid:e.preid,major:e.major,minor:e.minor,patch:e.patch||!e.major&&!e.minor&&!e.version,premajor:e.premajor,preminor:e.preminor,prepatch:e.prepatch,prerelease:e.prerelease,allowSameVersion:e[`allow-same-version`]};if(e.version){let t=e.version;[`patch`,`minor`,`major`,`prerelease`,`premajor`,`preminor`,`prepatch`].includes(t)?i[t]=!0:i.version=t}let a=process.cwd(),o=await v(a),s=o.version;if(!s)throw Error(`No version found in package.json`);let c=G(s,i,r.version||{});if(!i.allowSameVersion&&c===s)throw Error(`Version unchanged: ${s}. Use --allow-same-version to allow this.`);await t(await n(a),{...o,version:c}),l.success(`Version updated: ${s} → ${c}`)}catch(e){l.error(`Version update failed:`,e),process.exit(1)}}});async function q(e,t){let n=process.cwd(),r=await v(n),i=r.version,a=r.name;if(!a)throw Error(`Package name is required in package.json`);if(!i)throw Error(`Package version is required in package.json`);let o=(await g(n))?.name||`npm`,s={tag:`latest`,access:`public`,...t.npm},c=e.tag;if(!c&&i&&i.includes(`-`)){let e=i.match(/-(\w+)\.\d+$/);e&&(c=e[1])}c=c||s.tag||`latest`;let u=D(o,[`publish`,...(t=>{let n=[];e.tarball&&n.push(e.tarball),n.push(`--tag`,t);let r=e.access||s.access;return r&&n.push(`--access`,r),e.dryRun&&n.push(`--dry-run`),e.otp&&n.push(`--otp`,e.otp),n})(c)],{stdio:`inherit`,shell:!0});if(u.status!==0){l.error(`Publish failed with exit code ${u.status}`);return}let d=s.additionalTag;if(!e.dryRun&&d&&d!==c){let e=D(`npm`,[`dist-tag`,`add`,`${a}@${i}`,d],{cwd:n,stdio:`inherit`,shell:!0});if(e.status!==0){l.error(`Failed to add dist-tag with exit code ${e.status}`);return}}else d&&l.info(`Skipping dist-tag ${d} (same as publish tag ${c})`)}async function J(e,t){let n=process.cwd(),r=t?.tagPrefix;if(!r)throw Error(`Git tagPrefix is required`);let i=`${r}${e}`,a=t?.message?t.message(e):`chore: release ${i}`;await(0,O.exec)([`add`,`package.json`],n),await(0,O.exec)([`commit`,`-m`,a],n),await(0,O.exec)([`tag`,i,...t?.signTag?[`--sign`]:[]],n),t?.push&&(await(0,O.exec)([`push`],n),await(0,O.exec)([`push`,`--tags`],n))}const Y=c({meta:{name:`publish`,description:`Publish to registry`},args:{tag:{type:`string`,description:`Publish tag`},git:{type:`boolean`,description:`Also create git tag and commit`},access:{type:`string`,description:`Package access level (public, restricted)`},"dry-run":{type:`boolean`,description:`Dry run mode`},otp:{type:`string`,description:`One-time password for 2FA`}},async run({args:e}){try{let{config:t}=await b();if(await q({tag:e.tag,git:e.git,access:e.access||void 0,dryRun:e[`dry-run`],otp:e.otp},t.publish||{}),l.success(`Package published successfully`),e.git&&t.publish?.git){l.info(`Creating git tag and commit...`);let e=(await v(process.cwd())).version;e&&(await J(e,t.publish.git),l.success(`Git operations completed`))}}catch(e){l.error(`Publish failed:`,e),process.exit(1)}}}),X={npm:{outdated:[`outdated`],audit:[`audit`]},yarn:{outdated:[`outdated`,`-c`],audit:[`audit`]},pnpm:{outdated:[`outdated`],audit:[`audit`]},bun:{outdated:[`outdated`],audit:[`audit`]},deno:{outdated:null,audit:null}};async function Z(e=process.cwd(),t,r=!1){let{config:i}=await b({overrides:t?{audit:{dependencies:t}}:void 0}),a=i.audit?.dependencies||{};l.start(`Auditing dependencies...`);let o=!1;if(a.blocked&&a.blocked.length>0)try{let t=await v(e),n={...t.dependencies,...t.devDependencies},r=Object.keys(n).filter(e=>a.blocked?.includes(e));r.length>0&&(l.error(`Found ${r.length} blocked package(s): ${r.join(`, `)}`),o=!0)}catch(e){l.error(`Failed to check blocked packages:`,e),o=!0}if(a.outdated)try{let t=(await g(e))?.name||`npm`,n=X[t];n.outdated?D(t,n.outdated,{cwd:e,stdio:`inherit`,shell:!0}).status!==0&&l.warn(`Some dependencies are outdated`):l.info(`Skipping outdated check for ${t}`)}catch(e){l.error(`Failed to check outdated dependencies:`,e),o=!0}if(a.security)try{let t=(await g(e))?.name||`npm`,n=X[t];n.audit?D(t,n.audit,{cwd:e,stdio:`inherit`,shell:!0}).status!==0&&(o=!0):l.info(`Skipping security audit for ${t}`)}catch(e){l.error(`Failed to check security vulnerabilities:`,e),o=!0}if(a.licenses&&(a.licenses.allowed||a.licenses.blocked))try{let t=await n(e),r=await ne(e),i=[];for(let e of r)try{let n=await v(e);if(!n.name||e===t)continue;if(n.license){let e=Array.isArray(n.license)?n.license.join(`, `):n.license;if(a.licenses.blocked&&a.licenses.blocked.some(t=>e.includes(t))){i.push(`${n.name}: ${e}`);continue}a.licenses.allowed&&a.licenses.allowed.length>0&&(a.licenses.allowed.some(t=>e.includes(t))||i.push(`${n.name}: ${e}`))}}catch{}i.length>0&&(l.error(`Packages with invalid licenses:`),i.forEach(e=>l.error(` ${e}`)),o=!0)}catch(e){l.error(`Failed to check licenses:`,e),o=!0}return o||l.success(`Dependencies audit passed`),!o}async function ne(e){try{return await i([`node_modules/*/package.json`,`node_modules/@*/*/package.json`,`node_modules/@*/*/*/package.json`],{cwd:e,absolute:!0})}catch{return[]}}async function Q(e=process.cwd(),t){let{config:n}=await b({overrides:t?{audit:{structure:t}}:void 0}),r=n.audit?.structure||{};l.start(`Auditing project structure...`);let a=!1;if(r.required&&r.required.length>0){let t=[];for(let n of r.required)try{await ee(u(e,n))}catch{n.includes(`*`)||n.includes(`?`)?(await i([n],{cwd:e})).length===0&&t.push(n):t.push(n)}t.length>0&&(l.error(`Missing required file(s)/director(ies): ${t.join(`, `)}`),a=!0)}if(r.files&&r.files.length>0)for(let t of r.files)try{let n=await i([t.pattern],{cwd:e}),r=new RegExp(t.rule),o=n.filter(e=>!r.test(e));o.length>0&&(l.error(`${t.message}: ${o.slice(0,5).join(`, `)}${o.length>5?`...`:``}`),a=!0)}catch(e){l.error(`Failed to check file naming rule: ${t.pattern}`,e),a=!0}if(r.dirs&&r.dirs.length>0)for(let t of r.dirs)try{let n=await i([t.pattern],{cwd:e}),r=new RegExp(t.rule),o=n.filter(e=>!r.test(e));o.length>0&&(l.error(`${t.message}: ${o.slice(0,5).join(`, `)}${o.length>5?`...`:``}`),a=!0)}catch(e){l.error(`Failed to check directory naming rule: ${t.pattern}`,e),a=!0}return a||l.success(`Structure audit passed`),!a}async function re(e=process.cwd(),t=!1){let{config:n}=await b(),r=n.audit||{};l.start(`Running comprehensive project audit...`);let i=(await Promise.allSettled([Z(e,r.dependencies,t),Q(e,r.structure)])).filter(e=>e.status===`rejected`||e.status===`fulfilled`&&!e.value);return i.length===0?(l.success(`All audits passed`),!0):(l.error(`${i.length} audit(s) failed`),!1)}const ie=c({meta:{name:`audit`,description:`Audit code quality`},args:{dependencies:{type:`boolean`,description:`Dependencies audit`},structure:{type:`boolean`,description:`Project structure audit`},fix:{type:`boolean`,description:`Auto-fix issues`}},async run({args:e}){let t=process.cwd(),n=!0;if(!e.dependencies&&!e.structure)n=await re(t,e.fix);else{let r=[];e.dependencies&&r.push(()=>Z(t,void 0,e.fix)),e.structure&&r.push(()=>Q(t));for(let e of r)await e()||(n=!1)}n||(l.error(`Some audits failed`),process.exit(1))}}),ae=c({meta:{name:`add`,description:`Add dependencies`},args:{dev:{type:`boolean`,description:`Add as dev dependency`,alias:`D`}},async run({args:e,rawArgs:t}){t.length===0&&(l.error(`Please specify at least one package name`),l.info(`Example: basis add lodash`),process.exit(1));let n=t.filter(e=>!e.startsWith(`-`));n.length===0&&(l.error(`Please specify at least one package name`),process.exit(1));try{e.dev?(await d(n,{cwd:process.cwd()}),l.success(`Added ${n.join(`, `)} as dev dependencies`)):(await a(n,{cwd:process.cwd()}),l.success(`Added ${n.join(`, `)} as dependencies`))}catch(e){l.error(`Add packages failed:`,e),process.exit(1)}}}),oe=c({meta:{name:`remove`,description:`Remove dependencies`},async run({rawArgs:e}){e.length===0&&(l.error(`Please specify at least one package name`),l.info(`Example: basis remove lodash`),process.exit(1));let t=e.filter(e=>!e.startsWith(`-`));t.length===0&&(l.error(`Please specify at least one package name`),process.exit(1));try{await s(t,{cwd:process.cwd()}),l.success(`Removed ${t.join(`, `)}`)}catch(e){l.error(`Remove packages failed:`,e),process.exit(1)}}}),se=c({meta:{name:`dlx`,description:`Execute package without installation`},async run({rawArgs:e}){try{e.length===0&&(l.error(`Please specify a package to run`),process.exit(1));let[t,...n]=e;await o(t,{args:n,cwd:process.cwd()}),l.success(`Dlx completed`)}catch(e){l.error(`Dlx failed:`,e),process.exit(1)}}}),$=await v(import.meta.url);r(c({meta:{name:`basis`,description:$.description,version:$.version},subCommands:{init:k,lint:x,fmt:S,build:M,git:H,run:U,version:K,publish:Y,audit:ie,add:ae,remove:oe,dlx:se}}));export{};
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{_ as e}from"../_chunks/vendor/common-DNe_sHJp.mjs";import"../_chunks/config-Coiy-SOC.mjs";import"../_chunks/run-CYtHqbev.mjs";import{t}from"../_chunks/fmt-C7X2ZSv6.mjs";e(t);export{};
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{_ as e}from"../_chunks/vendor/common-DNe_sHJp.mjs";import"../_chunks/config-Coiy-SOC.mjs";import"../_chunks/run-CYtHqbev.mjs";import{t}from"../_chunks/lint-ESN87Ohj.mjs";e(t);export{};
@@ -1 +1 @@
1
- import{defineCommand as e}from"citty";import{consola as t}from"consola";import{dlx as n}from"nypm";import{loadConfig as r}from"../config.mjs";export const fmtCommand=e({meta:{name:`fmt`,description:`Format code`},async run({rawArgs:e}){let i=process.cwd(),{config:a}=await r(),o=[...a.fmt?.config||[],...e];try{await n(`oxfmt`,{args:o,cwd:i}),t.success(`Formatting completed`)}catch(e){t.error(`Formatting failed:`,e),process.exit(1)}}});
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{loadConfig as n}from"../config.mjs";import{runTool as r}from"../modules/run.mjs";export const fmtCommand=e({meta:{name:`fmt`,description:`Format code`},async run({rawArgs:e}){let{config:i}=await n(),a=i.fmt?.config||[];r({pkg:`oxfmt`,bin:`cli.js`,args:e.length>0?e:a}).status!==0&&process.exit(1),t.success(`Formatting completed`)}});
@@ -1 +1 @@
1
- import{defineCommand as e}from"citty";import{consola as t}from"consola";import{dlx as n}from"nypm";import{loadConfig as r}from"../config.mjs";export const lintCommand=e({meta:{name:`lint`,description:`Lint code`},async run({rawArgs:e}){let i=process.cwd(),{config:a}=await r(),o=[...a.lint?.config||[],...e];try{await n(`oxlint`,{args:o,cwd:i}),t.success(`Linting completed`)}catch(e){t.error(`Linting failed:`,e),process.exit(1)}}});
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{loadConfig as n}from"../config.mjs";import{runTool as r}from"../modules/run.mjs";export const lintCommand=e({meta:{name:`lint`,description:`Lint code`},async run({rawArgs:e}){let{config:i}=await n(),a=i.lint?.config||[];r({pkg:`oxlint`,bin:`cli.js`,args:e.length>0?e:a}).status!==0&&process.exit(1),t.success(`Linting completed`)}});
package/dist/config.d.mts CHANGED
@@ -1,8 +1,106 @@
1
- import { a as FmtConfig, c as LintConfig, d as RunConfig, h as VersionConfig, l as PublishConfig, n as BasisConfig, o as GitConfig, t as AuditConfig } from "./_chunks/types-D9xRZRDc.mjs";
2
- import * as c12 from "c12";
3
- import { LoadConfigOptions } from "c12";
4
- import { defineBuildConfig } from "@funish/build/config";
1
+ import { a as MinifyOptions, c as RolldownPluginOption, d as ResolvedConfig, i as InputOptions, l as ConfigLayerMeta, m as ResolveOptions, n as MinifyOptions$1, o as OutputOptions, r as TransformOptions, s as RolldownBuild, t as Options, u as LoadConfigOptions } from "./_chunks/vendor/common-C57wNPL5.mjs";
2
+ import { a as FmtConfig, c as LintConfig, d as RunConfig, h as VersionConfig, l as PublishConfig, n as BasisConfig, o as GitConfig, t as AuditConfig } from "./_chunks/types-DVbgCQzS.mjs";
5
3
 
4
+ //#region ../build/src/types.d.ts
5
+ interface BuildContext {
6
+ pkgDir: string;
7
+ pkg: {
8
+ name: string;
9
+ } & Record<string, unknown>;
10
+ }
11
+ type _BuildEntry = {
12
+ /**
13
+ * Output directory relative to project root.
14
+ *
15
+ * Defaults to `dist/` if not provided.
16
+ */
17
+ outDir?: string;
18
+ /**
19
+ * Avoid actual build but instead link to the source files.
20
+ */
21
+ stub?: boolean;
22
+ };
23
+ type BundleEntry = _BuildEntry & {
24
+ type: "bundle";
25
+ /**
26
+ * Entry point(s) to bundle relative to the project root.
27
+ * */
28
+ input: string | string[];
29
+ /**
30
+ * Minify the output using rolldown.
31
+ *
32
+ * Defaults to `false` if not provided.
33
+ */
34
+ minify?: boolean | "dce-only" | MinifyOptions;
35
+ /**
36
+ * Options passed to rolldown.
37
+ *
38
+ * See [rolldown config options](https://rolldown.rs/reference/config-options) for more details.
39
+ */
40
+ rolldown?: InputOptions & {
41
+ plugins?: RolldownPluginOption[];
42
+ };
43
+ /**
44
+ * Declaration generation options.
45
+ *
46
+ * See [rolldown-plugin-dts](https://github.com/sxzz/rolldown-plugin-dts) for more details.
47
+ *
48
+ * Options are inferred from the `tsconfig.json` file if available.
49
+ *
50
+ * Set to `false` to disable.
51
+ */
52
+ dts?: boolean | Options;
53
+ };
54
+ type TransformEntry = _BuildEntry & {
55
+ type: "transform";
56
+ /**
57
+ * Directory to transform relative to the project root.
58
+ */
59
+ input: string;
60
+ /**
61
+ * Minify the output using oxc-minify.
62
+ *
63
+ * Defaults to `false` if not provided.
64
+ */
65
+ minify?: boolean | MinifyOptions$1;
66
+ /**
67
+ * Options passed to oxc-transform.
68
+ *
69
+ * See [oxc-transform](https://www.npmjs.com/package/oxc-transform) for more details.
70
+ */
71
+ oxc?: TransformOptions;
72
+ /**
73
+ * Options passed to exsolve for module resolution.
74
+ *
75
+ * See [exsolve](https://github.com/unjs/exsolve) for more details.
76
+ */
77
+ resolve?: Omit<ResolveOptions, "from">;
78
+ /**
79
+ * A filter function to exclude files from being transformed.
80
+ */
81
+ filter?: (filePath: string) => boolean | Promise<boolean>;
82
+ /**
83
+ * If sets to `false`, or if the function returns `false`, declaration files won't be emitted for the module.
84
+ */
85
+ dts?: boolean | ((filePath: string) => boolean | Promise<boolean>);
86
+ };
87
+ type BuildEntry = BundleEntry | TransformEntry;
88
+ interface BuildHooks {
89
+ start?: (ctx: BuildContext) => void | Promise<void>;
90
+ end?: (ctx: BuildContext) => void | Promise<void>;
91
+ entries?: (entries: BuildEntry[], ctx: BuildContext) => void | Promise<void>;
92
+ rolldownConfig?: (cfg: InputOptions, ctx: BuildContext) => void | Promise<void>;
93
+ rolldownOutput?: (cfg: OutputOptions, res: RolldownBuild, ctx: BuildContext) => void | Promise<void>;
94
+ }
95
+ interface BuildConfig {
96
+ cwd?: string | URL;
97
+ entries?: (BuildEntry | string)[];
98
+ hooks?: BuildHooks;
99
+ }
100
+ //#endregion
101
+ //#region ../build/src/config.d.ts
102
+ declare function defineBuildConfig(config: BuildConfig): BuildConfig;
103
+ //#endregion
6
104
  //#region src/config.d.ts
7
105
  /**
8
106
  * Define a Basis configuration
@@ -11,7 +109,8 @@ declare function defineBasisConfig(config: BasisConfig): BasisConfig;
11
109
  /**
12
110
  * Load Basis configuration with intelligent upward search
13
111
  */
14
- declare function loadConfig(options?: LoadConfigOptions<BasisConfig>): Promise<c12.ResolvedConfig<{
112
+ declare function loadConfig(options?: LoadConfigOptions<BasisConfig>): Promise<ResolvedConfig<{
113
+ extends?: string | string[];
15
114
  lint?: LintConfig;
16
115
  fmt?: FmtConfig;
17
116
  git?: GitConfig;
@@ -19,6 +118,6 @@ declare function loadConfig(options?: LoadConfigOptions<BasisConfig>): Promise<c
19
118
  audit?: AuditConfig;
20
119
  version?: VersionConfig;
21
120
  publish?: PublishConfig;
22
- }, c12.ConfigLayerMeta>>;
121
+ }, ConfigLayerMeta>>;
23
122
  //#endregion
24
123
  export { defineBasisConfig, defineBuildConfig, loadConfig };
package/dist/config.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./_chunks/config-D9BuZxZJ.mjs";export{n as defineBasisConfig,e as defineBuildConfig,t as loadConfig};
1
+ import"./_chunks/vendor/common-DNe_sHJp.mjs";import{n as e,r as t,t as n}from"./_chunks/config-Coiy-SOC.mjs";export{n as defineBasisConfig,t as defineBuildConfig,e as loadConfig};
package/dist/index.d.mts CHANGED
@@ -1,2 +1,3 @@
1
- import { a as FmtConfig, c as LintConfig, d as RunConfig, f as StagedConfig, g as VersionOptions, h as VersionConfig, i as CommitMsgConfig, l as PublishConfig, m as ValidGitHook, n as BasisConfig, o as GitConfig, p as VALID_GIT_HOOKS, r as CommitMessage, s as InitOptions, t as AuditConfig, u as PublishOptions } from "./_chunks/types-D9xRZRDc.mjs";
1
+ import "./_chunks/vendor/common-C57wNPL5.mjs";
2
+ import { a as FmtConfig, c as LintConfig, d as RunConfig, f as StagedConfig, g as VersionOptions, h as VersionConfig, i as CommitMsgConfig, l as PublishConfig, m as ValidGitHook, n as BasisConfig, o as GitConfig, p as VALID_GIT_HOOKS, r as CommitMessage, s as InitOptions, t as AuditConfig, u as PublishOptions } from "./_chunks/types-DVbgCQzS.mjs";
2
3
  export { AuditConfig, BasisConfig, CommitMessage, CommitMsgConfig, FmtConfig, GitConfig, InitOptions, LintConfig, PublishConfig, PublishOptions, RunConfig, StagedConfig, VALID_GIT_HOOKS, ValidGitHook, VersionConfig, VersionOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funish/basis",
3
- "version": "0.2.6",
3
+ "version": "0.2.8-edge.0",
4
4
  "description": "A modern development toolkit with unified CLI for package management, versioning, publishing, code quality, and Git workflow automation.",
5
5
  "keywords": [
6
6
  "basis",
@@ -40,7 +40,9 @@
40
40
  "directory": "packages/basis"
41
41
  },
42
42
  "bin": {
43
- "basis": "dist/cli.mjs"
43
+ "basis": "dist/cli/basis.mjs",
44
+ "oxfmt": "dist/cli/oxfmt.mjs",
45
+ "oxlint": "dist/cli/oxlint.mjs"
44
46
  },
45
47
  "files": [
46
48
  "dist"
@@ -68,17 +70,18 @@
68
70
  "dugite": "3.2.0",
69
71
  "jiti": "2.6.1",
70
72
  "nypm": "0.6.5",
73
+ "oxfmt": "0.36.0",
74
+ "oxlint": "1.51.0",
71
75
  "pathe": "2.0.3",
72
76
  "picomatch": "4.0.3",
73
77
  "pkg-types": "2.3.0",
74
78
  "semver": "7.7.4",
75
79
  "tinyglobby": "0.2.15",
76
- "@funish/build": "0.0.1"
80
+ "@funish/build": "0.0.3"
77
81
  },
78
82
  "devDependencies": {
79
83
  "@types/picomatch": "4.0.2",
80
- "@types/semver": "7.7.1",
81
- "oxlint-tsgolint": "0.15.0"
84
+ "@types/semver": "7.7.1"
82
85
  },
83
86
  "peerDependencies": {
84
87
  "oxlint-tsgolint": "0.15.0"
@@ -1 +0,0 @@
1
- import{findWorkspaceDir as e}from"pkg-types";import{loadConfig as t}from"c12";import{dirname as n}from"pathe";import{defineBuildConfig as r}from"@funish/build/config";function i(e){return e}async function a(r={}){if(r.cwd)return await t({name:`basis`,cwd:r.cwd,...r,defaults:{...r.defaults}});let i=process.cwd(),a=await e(i);for(;;){let e=await t({name:`basis`,cwd:i,...r,defaults:{...r.defaults}});if(e._configFile||i===a)return e;i=n(i)}}export{r as n,a as r,i as t};
package/dist/cli.mjs DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{r as e}from"./_chunks/config-D9BuZxZJ.mjs";import{defineCommand as t,runMain as n}from"citty";import{readPackageJSON as r,resolvePackageJSON as i,writePackageJSON as a}from"pkg-types";import{consola as o}from"consola";import{readFile as s,stat as c,writeFile as l}from"node:fs/promises";import{exec as u,setupEnvironment as d}from"dugite";import{loadConfig as f}from"c12";import{addDependency as p,addDevDependency as m,detectPackageManager as h,dlx as g,removeDependency as _,runScript as v}from"nypm";import{resolve as y}from"pathe";import{build as ee}from"@funish/build";import{execSync as b}from"node:child_process";import x from"picomatch";import{createJiti as S}from"jiti";import{existsSync as C}from"node:fs";import w from"semver";import{glob as T}from"tinyglobby";async function E(e=process.cwd(),t={}){let{force:n=!1,skipGitCheck:r=!1}=t;o.start(`Initializing basis configuration`);let i=(await f({cwd:e,name:`basis`}))._configFile;if(i&&!n)return o.error(`Configuration file already exists: ${i}`),o.info(`Use --force to overwrite.`),!1;let a=(await h(e))?.name||`npm`,s=a===`npm`?`npx`:a,c={git:{hooks:{"pre-commit":`${s} basis git staged`,"commit-msg":`${s} basis git lint-commit`},staged:{rules:{"**/*.{ts,tsx,js,jsx}":`basis lint`,"**/*.{json,md,yml,yaml}":`basis fmt`}}}},d=`import { defineBasisConfig } from "@funish/basis/config";
3
-
4
- export default defineBasisConfig(${JSON.stringify(c,null,2)});
5
- `,p=`${e}/basis.config.ts`;if(await l(p,d,`utf8`),o.success(`Configuration created in ${p}`),!r)try{await u([`--version`],e),o.info(`Git detected`)}catch{o.info(`Git not found`)}return o.success(`Basis initialization completed!`),o.info(`Run 'basis git setup' to setup Git hooks`),!0}const D=t({meta:{name:`init`,description:`Initialize configuration`},args:{force:{type:`boolean`,description:`Overwrite existing configuration`},"skip-git-check":{type:`boolean`,description:`Skip git directory check`},"skip-install":{type:`boolean`,description:`Skip dependency installation`}},async run({args:e}){try{await E(process.cwd(),{force:e.force,skipGitCheck:e[`skip-git-check`],skipInstall:e[`skip-install`]})}catch(e){o.error(`Init failed:`,e),process.exit(1)}}}),O=t({meta:{name:`lint`,description:`Lint code`},async run({rawArgs:t}){let n=process.cwd(),{config:r}=await e(),i=[...r.lint?.config||[],...t];try{await g(`oxlint`,{args:i,cwd:n}),o.success(`Linting completed`)}catch(e){o.error(`Linting failed:`,e),process.exit(1)}}}),k=t({meta:{name:`fmt`,description:`Format code`},async run({rawArgs:t}){let n=process.cwd(),{config:r}=await e(),i=[...r.fmt?.config||[],...t];try{await g(`oxfmt`,{args:i,cwd:n}),o.success(`Formatting completed`)}catch(e){o.error(`Formatting failed:`,e),process.exit(1)}}}),A=t({meta:{name:`check`,description:`Type check code`},async run({rawArgs:e}){try{await g(`vue-tsc`,{args:[`--noEmit`,...e],cwd:process.cwd()}),o.success(`Type checking completed`)}catch(e){o.error(`Type checking failed:`,e),process.exit(1)}}}),j=t({meta:{name:`build`,description:`Build project`},args:{dir:{type:`string`,description:`Project directory`,default:`.`},stub:{type:`boolean`,description:`Generate stub files`,default:!1}},async run({args:e}){let t=y(e.dir||`.`);try{let{config:n={}}=await f({name:`isbuild`,configFile:`build.config`,cwd:t}),r=(n.entries||[]).map(t=>{if(typeof t==`string`){let[n,r]=t.split(`:`);return n.endsWith(`/`)?{type:`transform`,input:n,outDir:r,stub:e.stub}:{type:`bundle`,input:n.split(`,`),outDir:r,stub:e.stub}}return{...t,stub:e.stub}});(!r||r.length===0)&&(o.error(`No build entries specified in build.config.`),process.exit(1)),await ee({cwd:t,...n,entries:r}),o.success(`Build completed`)}catch(e){o.error(`Build failed:`,e),process.exit(1)}}});async function M(){try{let e=b(`git --exec-path`,{encoding:`utf8`}).trim();if(e){let t=d({LOCAL_GIT_DIRECTORY:y(e,`..`,`..`,`..`)});Object.assign(process.env,t.env),o.debug(`Using system Git from: ${t.gitLocation}`)}}catch{o.debug(`System Git not found, dugite will use embedded Git`)}}M();async function N(e){try{let t=(await u([`diff`,`--cached`,`--name-only`],e)).stdout.trim().split(`
6
- `).filter(Boolean),n=await u([`diff`,`--cached`,`--name-only`,`--diff-filter=D`],e),r=new Set(n.stdout.trim().split(`
7
- `).filter(Boolean));return t.filter(e=>!r.has(e))}catch{return[]}}async function P(t=process.cwd()){let{config:n}=await e(),r=n.git?.staged?.rules||{};if(Object.keys(r).length===0)return o.warn(`No staged rules configured. Add git.staged.rules to your basis.config.ts`),!0;let i=await N(t);if(i.length===0)return o.info(`No staged files to check`),!0;o.start(`Checking ${i.length} staged file(s)`);let a=!1,s=new Set;for(let[e,n]of Object.entries(r)){let r=x(e),c=i.filter(e=>!s.has(e)&&r(e));if(c.length!==0){o.info(`Running ${n} for ${c.length} file(s) matching ${e}`);try{let e=await u([`status`,`--porcelain`],t),r=new Set;e.stdout.trim().split(`
8
- `).filter(Boolean).forEach(e=>{let t=e.match(/^(..)\s+(.+)$/);if(!t)return;let[,n,i]=t;(n[1]===`M`||n===` M`)&&r.add(i)});let[i,...a]=n.split(` `);b(`${i} ${a.join(` `)}`,{cwd:t,stdio:`inherit`});let l=await u([`status`,`--porcelain`],t),d=new Set;l.stdout.trim().split(`
9
- `).filter(Boolean).forEach(e=>{let t=e.match(/^(..)\s+(.+)$/);if(!t)return;let[,n,i]=t;(n[1]===`M`||n===` M`)&&(c.includes(i)?d.add(i):r.has(i)||d.add(i))}),d.size>0&&(await u([`add`,...Array.from(d)],t),o.info(`Re-staged ${d.size} file(s) after formatting`)),c.forEach(e=>s.add(e))}catch(t){a=!0,o.error(`Staged check failed for pattern '${e}':`,t)}}}return a?(o.error(`Some staged files checks failed`),!1):(o.success(`Staged files check passed`),!0)}const F=[`feat`,`fix`,`docs`,`style`,`refactor`,`perf`,`test`,`build`,`ci`,`chore`,`revert`];function I(e){let t=e.trim().split(`
10
- `)[0],n=t.match(/^(\w+)(\(([^)]+)\))?(!)?:\s*(.+)$/);if(!n)return null;let[,r,,i,,a]=n;return{type:r,scope:i,subject:a,isBreaking:t.includes(`!`)||e.includes(`BREAKING CHANGE:`)}}async function L(t=process.cwd()){let{config:n}=await e(),r=n.git?.commitMsg,i=r?.types||F,a=r?.maxLength||72,c=r?.minLength||10,l=r?.scopeRequired||!1,d=r?.allowedScopes||[],f;try{let e=y(t,`.git/COMMIT_EDITMSG`);try{f=(await s(e)).toString(`utf8`)}catch{f=(await u([`log`,`-1`,`--pretty=%B`],t)).stdout.trim()}}catch(e){return o.error(`Failed to read commit message:`,e),!1}let p=[],m=I(f);if(!m)return o.error(`Invalid commit format. Expected: type(scope): subject`),!1;i.includes(m.type)||p.push(`Invalid type '${m.type}'. Allowed: ${i.join(`, `)}`);let h=f.split(`
11
- `)[0];return h.length>a&&p.push(`Header too long (${h.length} chars). Max: ${a}`),h.length<c&&p.push(`Header too short (${h.length} chars). Min: ${c}`),l&&!m.scope&&p.push(`Scope is required`),m.scope&&d.length>0&&!d.includes(m.scope)&&p.push(`Invalid scope '${m.scope}'. Allowed: ${d.join(`, `)}`),p.length>0?(o.error(`Invalid commit message:`),p.forEach(e=>o.error(` ${e}`)),!1):(o.success(`Commit message validation passed`),!0)}async function R(t=process.cwd()){let{config:n}=await e(),r=n.git?.hooks;if(!r||Object.keys(r).length===0)return o.warn(`No Git hooks configured`),!0;let i=y(t,`.git/hooks`);try{for(let[e,t]of Object.entries(r))await l(y(i,e),`#!/bin/sh\n${t}\n`,{mode:493}),o.success(`Created ${e} hook`);return!0}catch(e){return o.error(`Failed to setup Git hooks:`,e),!1}}async function z(e=process.cwd()){return o.start(`Setting up Git configuration`),await R(e)?(o.success(`Git setup completed`),!0):!1}const B=t({meta:{name:`git`,description:`Git operations`},async run({rawArgs:e}){let t=e[0];if(!t){o.info(`Available subcommands: staged, lint-commit, setup`),o.info(`Git passthrough mode: basis git <git-command>`);return}switch(t){case`staged`:await P()||process.exit(1);return;case`lint-commit`:await L()||process.exit(1);return;case`setup`:await z()||process.exit(1);return;default:try{let t=await u(e,process.cwd(),{processCallback:e=>{e.stdout?.on(`data`,e=>{process.stdout.write(e)}),e.stderr?.on(`data`,e=>{process.stderr.write(e)})}});if(t.exitCode!==0)throw Error(`git exited with code ${t.exitCode}`)}catch(e){o.error(`Git operation failed:`,e),process.exit(1)}}}}),V=t({meta:{name:`run`,description:`Run scripts or files`},async run({rawArgs:t}){t.length===0&&(o.error(`Please specify a script name or file path`),process.exit(1));let[n,...r]=t,i=process.cwd(),{config:a}=await e(),s=a.run?.config,c=y(i,n);if(C(c))try{let e=S(i,s),n=e.esmResolve(c);process.argv=[process.argv[0],n,...t.slice(1)],await e.import(n);return}catch(e){o.error(`Failed to run file:`),o.error(` ${String(e)}`),process.exit(1)}try{await v(n,{cwd:i,args:r})}catch(e){o.error(`Failed to run script "${n}":`),o.error(` ${String(e)}`),process.exit(1)}}});function H(e,t,n){if(t.version){if(w.valid(t.version))return t.version;throw Error(`Invalid version format: ${t.version}. Please use semantic versioning format (e.g., 1.0.0, 2.1.0-alpha.1)`)}if(!w.valid(e))throw Error(`Invalid current version format: ${e}. Please fix version in package.json to use semantic versioning format (e.g., 1.0.0)`);let r=w.prerelease(e),i=t.preid||(r&&typeof r[0]==`string`?r[0]:null)||n.preid||`edge`,a=`patch`;t.major?a=`major`:t.minor?a=`minor`:t.premajor?a=`premajor`:t.preminor?a=`preminor`:t.prepatch?a=`prepatch`:t.prerelease?a=r?`prerelease`:`prepatch`:t.fromGit&&(a=`patch`);let o=a===`prerelease`||a.startsWith(`pre`)?w.inc(e,a,i):w.inc(e,a);if(!o)throw Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return o}const U=t({meta:{name:`version`,description:`Update package version`},args:{version:{type:`positional`,description:`Version to set (patch, minor, major, prerelease, or specific version)`,required:!1},preid:{type:`string`,description:`Prerelease identifier (alpha, beta, rc)`},major:{type:`boolean`,description:`Bump major version`},minor:{type:`boolean`,description:`Bump minor version`},patch:{type:`boolean`,description:`Bump patch version`},premajor:{type:`boolean`,description:`Bump premajor version`},preminor:{type:`boolean`,description:`Bump preminor version`},prepatch:{type:`boolean`,description:`Bump prepatch version`},prerelease:{type:`boolean`,description:`Bump prerelease version`},"allow-same-version":{type:`boolean`,description:`Allow same version`}},async run({args:t}){try{let{config:n}=await e(),s={preid:t.preid,major:t.major,minor:t.minor,patch:t.patch||!t.major&&!t.minor&&!t.version,premajor:t.premajor,preminor:t.preminor,prepatch:t.prepatch,prerelease:t.prerelease,allowSameVersion:t[`allow-same-version`]};if(t.version){let e=t.version;[`patch`,`minor`,`major`,`prerelease`,`premajor`,`preminor`,`prepatch`].includes(e)?s[e]=!0:s.version=e}let c=process.cwd(),l=await r(c),u=l.version;if(!u)throw Error(`No version found in package.json`);let d=H(u,s,n.version||{});if(!s.allowSameVersion&&d===u)throw Error(`Version unchanged: ${u}. Use --allow-same-version to allow this.`);await a(await i(c),{...l,version:d}),o.success(`Version updated: ${u} → ${d}`)}catch(e){o.error(`Version update failed:`,e),process.exit(1)}}});async function W(e,t){let n=process.cwd(),i=await r(n),a=i.version,s=i.name;if(!s)throw Error(`Package name is required in package.json`);if(!a)throw Error(`Package version is required in package.json`);let c=(await h(n))?.name||`npm`,l={tag:`latest`,access:`public`,...t.npm},u=e.tag;if(!u&&a&&a.includes(`-`)){let e=a.match(/-(\w+)\.\d+$/);e&&(u=e[1])}u=u||l.tag||`latest`,b(`${c} publish ${(t=>{let n=[];e.tarball&&n.push(e.tarball),n.push(`--tag`,t);let r=e.access||l.access;return r&&n.push(`--access`,r),e.dryRun&&n.push(`--dry-run`),e.otp&&n.push(`--otp`,e.otp),n})(u).join(` `)}`,{stdio:`inherit`});let d=l.additionalTag;!e.dryRun&&d&&d!==u?b(`npm dist-tag add ${s}@${a} ${d}`,{cwd:n,stdio:`inherit`}):d&&o.info(`Skipping dist-tag ${d} (same as publish tag ${u})`)}async function G(e,t){let n=process.cwd(),r=t?.tagPrefix;if(!r)throw Error(`Git tagPrefix is required`);let i=`${r}${e}`,a=t?.message?t.message(e):`chore: release ${i}`;await u([`add`,`package.json`],n),await u([`commit`,`-m`,a],n),await u([`tag`,i,...t?.signTag?[`--sign`]:[]],n),t?.push&&(await u([`push`],n),await u([`push`,`--tags`],n))}const K=t({meta:{name:`publish`,description:`Publish to registry`},args:{tag:{type:`string`,description:`Publish tag`},git:{type:`boolean`,description:`Also create git tag and commit`},access:{type:`string`,description:`Package access level (public, restricted)`},"dry-run":{type:`boolean`,description:`Dry run mode`},otp:{type:`string`,description:`One-time password for 2FA`}},async run({args:t}){try{let{config:n}=await e();if(await W({tag:t.tag,git:t.git,access:t.access||void 0,dryRun:t[`dry-run`],otp:t.otp},n.publish||{}),o.success(`Package published successfully`),t.git&&n.publish?.git){o.info(`Creating git tag and commit...`);let e=(await r(process.cwd())).version;e&&(await G(e,n.publish.git),o.success(`Git operations completed`))}}catch(e){o.error(`Publish failed:`,e),process.exit(1)}}}),q={npm:{outdated:[`outdated`],audit:[`audit`]},yarn:{outdated:[`outdated`,`-c`],audit:[`audit`]},pnpm:{outdated:[`outdated`],audit:[`audit`]},bun:{outdated:[`outdated`],audit:[`audit`]},deno:{outdated:null,audit:null}};async function J(t=process.cwd(),n,a=!1){let{config:s}=await e({overrides:n?{audit:{dependencies:n}}:void 0}),c=s.audit?.dependencies||{};o.start(`Auditing dependencies...`);let l=!1;if(c.blocked&&c.blocked.length>0)try{let e=await r(t),n={...e.dependencies,...e.devDependencies},i=Object.keys(n).filter(e=>c.blocked?.includes(e));i.length>0&&(o.error(`Found ${i.length} blocked package(s): ${i.join(`, `)}`),l=!0)}catch(e){o.error(`Failed to check blocked packages:`,e),l=!0}if(c.outdated)try{let e=(await h(t))?.name||`npm`,n=q[e];if(!n.outdated)o.info(`Skipping outdated check for ${e}`);else try{b(`${e} ${n.outdated.join(` `)}`,{cwd:t,stdio:`inherit`})}catch{o.warn(`Some dependencies are outdated`)}}catch(e){o.error(`Failed to check outdated dependencies:`,e),l=!0}if(c.security)try{let e=(await h(t))?.name||`npm`,n=q[e];if(!n.audit)o.info(`Skipping security audit for ${e}`);else try{b(`${e} ${n.audit.join(` `)}`,{cwd:t,stdio:`inherit`})}catch{l=!0}}catch(e){o.error(`Failed to check security vulnerabilities:`,e),l=!0}if(c.licenses&&(c.licenses.allowed||c.licenses.blocked))try{let e=await i(t),n=await Y(t),a=[];for(let t of n)try{let n=await r(t);if(!n.name||t===e)continue;if(n.license){let e=Array.isArray(n.license)?n.license.join(`, `):n.license;if(c.licenses.blocked&&c.licenses.blocked.some(t=>e.includes(t))){a.push(`${n.name}: ${e}`);continue}c.licenses.allowed&&c.licenses.allowed.length>0&&(c.licenses.allowed.some(t=>e.includes(t))||a.push(`${n.name}: ${e}`))}}catch{}a.length>0&&(o.error(`Packages with invalid licenses:`),a.forEach(e=>o.error(` ${e}`)),l=!0)}catch(e){o.error(`Failed to check licenses:`,e),l=!0}return l||o.success(`Dependencies audit passed`),!l}async function Y(e){try{return await T([`node_modules/*/package.json`,`node_modules/@*/*/package.json`,`node_modules/@*/*/*/package.json`],{cwd:e,absolute:!0})}catch{return[]}}async function X(t=process.cwd(),n){let{config:r}=await e({overrides:n?{audit:{structure:n}}:void 0}),i=r.audit?.structure||{};o.start(`Auditing project structure...`);let a=!1;if(i.required&&i.required.length>0){let e=[];for(let n of i.required)try{await c(y(t,n))}catch{n.includes(`*`)||n.includes(`?`)?(await T([n],{cwd:t})).length===0&&e.push(n):e.push(n)}e.length>0&&(o.error(`Missing required file(s)/director(ies): ${e.join(`, `)}`),a=!0)}if(i.files&&i.files.length>0)for(let e of i.files)try{let n=await T([e.pattern],{cwd:t}),r=new RegExp(e.rule),i=n.filter(e=>!r.test(e));i.length>0&&(o.error(`${e.message}: ${i.slice(0,5).join(`, `)}${i.length>5?`...`:``}`),a=!0)}catch(t){o.error(`Failed to check file naming rule: ${e.pattern}`,t),a=!0}if(i.dirs&&i.dirs.length>0)for(let e of i.dirs)try{let n=await T([e.pattern],{cwd:t}),r=new RegExp(e.rule),i=n.filter(e=>!r.test(e));i.length>0&&(o.error(`${e.message}: ${i.slice(0,5).join(`, `)}${i.length>5?`...`:``}`),a=!0)}catch(t){o.error(`Failed to check directory naming rule: ${e.pattern}`,t),a=!0}return a||o.success(`Structure audit passed`),!a}async function Z(t=process.cwd(),n=!1){let{config:r}=await e(),i=r.audit||{};o.start(`Running comprehensive project audit...`);let a=(await Promise.allSettled([J(t,i.dependencies,n),X(t,i.structure)])).filter(e=>e.status===`rejected`||e.status===`fulfilled`&&!e.value);return a.length===0?(o.success(`All audits passed`),!0):(o.error(`${a.length} audit(s) failed`),!1)}const Q=t({meta:{name:`audit`,description:`Audit code quality`},args:{dependencies:{type:`boolean`,description:`Dependencies audit`},structure:{type:`boolean`,description:`Project structure audit`},fix:{type:`boolean`,description:`Auto-fix issues`}},async run({args:e}){let t=process.cwd(),n=!0;if(!e.dependencies&&!e.structure)n=await Z(t,e.fix);else{let r=[];e.dependencies&&r.push(()=>J(t,void 0,e.fix)),e.structure&&r.push(()=>X(t));for(let e of r)await e()||(n=!1)}n||(o.error(`Some audits failed`),process.exit(1))}}),te=t({meta:{name:`add`,description:`Add dependencies`},args:{dev:{type:`boolean`,description:`Add as dev dependency`,alias:`D`}},async run({args:e,rawArgs:t}){t.length===0&&(o.error(`Please specify at least one package name`),o.info(`Example: basis add lodash`),process.exit(1));let n=t.filter(e=>!e.startsWith(`-`));n.length===0&&(o.error(`Please specify at least one package name`),process.exit(1));try{e.dev?(await m(n,{cwd:process.cwd()}),o.success(`Added ${n.join(`, `)} as dev dependencies`)):(await p(n,{cwd:process.cwd()}),o.success(`Added ${n.join(`, `)} as dependencies`))}catch(e){o.error(`Add packages failed:`,e),process.exit(1)}}}),ne=t({meta:{name:`remove`,description:`Remove dependencies`},async run({rawArgs:e}){e.length===0&&(o.error(`Please specify at least one package name`),o.info(`Example: basis remove lodash`),process.exit(1));let t=e.filter(e=>!e.startsWith(`-`));t.length===0&&(o.error(`Please specify at least one package name`),process.exit(1));try{await _(t,{cwd:process.cwd()}),o.success(`Removed ${t.join(`, `)}`)}catch(e){o.error(`Remove packages failed:`,e),process.exit(1)}}}),re=t({meta:{name:`dlx`,description:`Execute package without installation`},async run({rawArgs:e}){try{e.length===0&&(o.error(`Please specify a package to run`),process.exit(1));let[t,...n]=e;await g(t,{args:n,cwd:process.cwd()}),o.success(`Dlx completed`)}catch(e){o.error(`Dlx failed:`,e),process.exit(1)}}}),$=await r(import.meta.url);n(t({meta:{name:`basis`,description:$.description,version:$.version},subCommands:{init:D,lint:O,fmt:k,check:A,build:j,git:B,run:V,version:U,publish:K,audit:Q,add:te,remove:ne,dlx:re}}));export{};
@@ -1,2 +0,0 @@
1
- import { type CommandDef, type ArgsDef } from "citty";
2
- export declare const checkCommand: CommandDef<ArgsDef>;
@@ -1 +0,0 @@
1
- import{defineCommand as e}from"citty";import{consola as t}from"consola";import{dlx as n}from"nypm";export const checkCommand=e({meta:{name:`check`,description:`Type check code`},async run({rawArgs:e}){try{await n(`vue-tsc`,{args:[`--noEmit`,...e],cwd:process.cwd()}),t.success(`Type checking completed`)}catch(e){t.error(`Type checking failed:`,e),process.exit(1)}}});
File without changes