@funish/basis 0.2.7 → 0.2.8-edge.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/_chunks/config-lvw40IpZ.mjs +1 -0
  2. package/dist/_chunks/fmt-9Yi9STzz.mjs +1 -0
  3. package/dist/_chunks/lint-3A6_NhRY.mjs +1 -0
  4. package/dist/_chunks/run-D8ZiNeaU.mjs +1 -0
  5. package/dist/_chunks/{types-D97hRU-z.d.mts → types-C-71QzwD.d.mts} +6 -5
  6. package/dist/cli/basis.mjs +11 -0
  7. package/dist/cli/oxfmt.d.mts +1 -0
  8. package/dist/cli/oxfmt.mjs +2 -0
  9. package/dist/cli/oxlint.d.mts +1 -0
  10. package/dist/cli/oxlint.mjs +2 -0
  11. package/dist/config.d.mts +6 -6967
  12. package/dist/config.mjs +1 -1
  13. package/dist/index.d.mts +1 -2
  14. package/package.json +5 -3
  15. package/dist/_chunks/common-ImpHew-F-C_Vy_bWl.mjs +0 -563
  16. package/dist/_chunks/config-DlKQJJuJ.mjs +0 -1
  17. package/dist/_chunks/dist-DmC4QnLo-DOtdNTJ9.mjs +0 -1
  18. package/dist/_chunks/jiti-4UP3iYSN.mjs +0 -1
  19. package/dist/_chunks/jiti-BTGRq7zm-CIyI5D4F.mjs +0 -1
  20. package/dist/_chunks/json5-jlDEA_LV-COBYYABw.mjs +0 -1
  21. package/dist/_chunks/json5-yz56pVhc.mjs +0 -1
  22. package/dist/_chunks/jsonc-BQ0-fIlR.mjs +0 -1
  23. package/dist/_chunks/jsonc-h2mYQXaC-DrYrX9nH.mjs +0 -1
  24. package/dist/_chunks/ohash-CBmXOb0i.mjs +0 -1
  25. package/dist/_chunks/ohash-auviw4oE-C1rS-sj5.mjs +0 -1
  26. package/dist/_chunks/prompt-B0wRZcxM.mjs +0 -1
  27. package/dist/_chunks/prompt-B56gTa4S-DU9z28wS-C5xwSzir.mjs +0 -1
  28. package/dist/_chunks/prompt-DWoeycZC-CrPLiZ-7.mjs +0 -1
  29. package/dist/_chunks/resolver-j7HY1N36-CYXyUckt-KaY2bzL2.mjs +0 -1
  30. package/dist/_chunks/rolldown-runtime-coR7_hWt.mjs +0 -1
  31. package/dist/_chunks/toml-Db_vu9L2.mjs +0 -1
  32. package/dist/_chunks/toml-DpopYhMQ-Cm2FvyAB.mjs +0 -1
  33. package/dist/_chunks/trace-DE8F1ZUa-BjFwYDv5.mjs +0 -1
  34. package/dist/_chunks/tsc-DYjBCyQo-W841VDnt.mjs +0 -1
  35. package/dist/_chunks/vendor/common-BKG-EppI.mjs +0 -352
  36. package/dist/_chunks/vendor/common-BpqHhQqH.d.mts +0 -359
  37. package/dist/_chunks/yaml-Bk1o9q2C.mjs +0 -1
  38. package/dist/_chunks/yaml-rm6ZZAQq-BzQnHREY.mjs +0 -1
  39. package/dist/cli.mjs +0 -21
  40. /package/dist/{cli.d.mts → cli/basis.d.mts} +0 -0
@@ -0,0 +1 @@
1
+ import{loadConfig as e}from"c12";import{findWorkspaceDir as t}from"pkg-types";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 e({name:`basis`,cwd:r.cwd,...r,defaults:{...r.defaults}});let i=process.cwd(),a=await t(i);for(;;){let t=await e({name:`basis`,cwd:i,...r,defaults:{...r.defaults}});if(t._configFile||i===a)return t;i=n(i)}}export{r as n,a as r,i as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./config-lvw40IpZ.mjs";import{t}from"./run-D8ZiNeaU.mjs";import{defineCommand as n}from"citty";import{consola as r}from"consola";const i=n({meta:{name:`fmt`,description:`Format code`},async run({rawArgs:n}){let{config:i}=await e(),a=i.fmt?.config||[];t({pkg:`oxfmt`,bin:`cli.js`,args:n.length>0?n:a}).status!==0&&process.exit(1),r.success(`Formatting completed`)}});export{i as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./config-lvw40IpZ.mjs";import{t}from"./run-D8ZiNeaU.mjs";import{defineCommand as n}from"citty";import{consola as r}from"consola";const i=n({meta:{name:`lint`,description:`Lint code`},async run({rawArgs:n}){let{config:i}=await e(),a=i.lint?.config||[];t({pkg:`oxlint`,bin:`cli.js`,args:n.length>0?n:a}).status!==0&&process.exit(1),r.success(`Linting completed`)}});export{i as t};
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"node:module";import{dirname as t,resolve as n}from"pathe";import{consola as r}from"consola";import{spawnSync as i}from"node:child_process";function a(a){let{pkg:o,bin:s,args:c}=a,l=n(t(e(import.meta.url).resolve(o)),s),u=i(process.execPath,[l,...c],{stdio:`inherit`,shell:!1});return u.error&&r.error(u.error),u.status!==0&&r.error(`${o} failed with exit code ${u.status}`),u}export{a as t};
@@ -1,4 +1,5 @@
1
- import { a as GitConfig$1, i as JitiOptions } from "./vendor/common-BpqHhQqH.mjs";
1
+ import { GitConfig } from "pkg-types";
2
+ import { JitiOptions } from "jiti";
2
3
 
3
4
  //#region src/types.d.ts
4
5
  interface BasisConfig {
@@ -6,7 +7,7 @@ interface BasisConfig {
6
7
  extends?: string | string[];
7
8
  lint?: LintConfig;
8
9
  fmt?: FmtConfig;
9
- git?: GitConfig;
10
+ git?: GitConfig$1;
10
11
  run?: RunConfig;
11
12
  audit?: AuditConfig;
12
13
  version?: VersionConfig;
@@ -36,11 +37,11 @@ interface StagedConfig {
36
37
  /**
37
38
  * Git command configuration
38
39
  */
39
- interface GitConfig {
40
+ interface GitConfig$1 {
40
41
  /** Git hooks */
41
42
  hooks?: Partial<Record<ValidGitHook, string>>;
42
43
  /** Git configuration */
43
- config?: GitConfig$1;
44
+ config?: GitConfig;
44
45
  /** Commit message validation */
45
46
  commitMsg?: CommitMsgConfig;
46
47
  /** Staged files check */
@@ -192,4 +193,4 @@ interface PublishOptions {
192
193
  otp?: string;
193
194
  }
194
195
  //#endregion
195
- export { FmtConfig as a, LintConfig as c, RunConfig as d, StagedConfig as f, VersionOptions as g, VersionConfig as h, CommitMsgConfig as i, PublishConfig as l, ValidGitHook as m, BasisConfig as n, GitConfig as o, VALID_GIT_HOOKS as p, CommitMessage as r, InitOptions as s, AuditConfig as t, PublishOptions as u };
196
+ export { FmtConfig as a, LintConfig as c, RunConfig as d, StagedConfig as f, VersionOptions as g, VersionConfig as h, CommitMsgConfig as i, PublishConfig as l, ValidGitHook as m, BasisConfig as n, GitConfig$1 as o, VALID_GIT_HOOKS as p, CommitMessage as r, InitOptions as s, AuditConfig as t, PublishOptions as u };
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import{r as e}from"../_chunks/config-lvw40IpZ.mjs";import"../_chunks/run-D8ZiNeaU.mjs";import{t}from"../_chunks/lint-3A6_NhRY.mjs";import{t as n}from"../_chunks/fmt-9Yi9STzz.mjs";import{loadConfig as r}from"c12";import{readPackageJSON as i,resolvePackageJSON as a,writePackageJSON as o}from"pkg-types";import{resolve as s}from"pathe";import{defineCommand as c,runMain as l}from"citty";import{consola as u}from"consola";import{readFile as d,stat as f,writeFile as p}from"node:fs/promises";import{exec as m,setupEnvironment as h}from"dugite";import{addDependency as g,addDevDependency as _,detectPackageManager as v,dlx as y,removeDependency as b,runScript as x}from"nypm";import{execSync as S,spawnSync as C}from"node:child_process";import{build as w}from"@funish/build";import T from"picomatch";import{createJiti as ee}from"jiti";import{existsSync as E}from"node:fs";import D from"semver";import{glob as O}from"tinyglobby";async function k(e=process.cwd(),t={}){let{force:n=!1,skipGitCheck:i=!1}=t;u.start(`Initializing basis configuration`);let a=(await r({cwd:e,name:`basis`}))._configFile;if(a&&!n)return u.error(`Configuration file already exists: ${a}`),u.info(`Use --force to overwrite.`),!1;let o=(await v(e))?.name||`npm`,s=o===`npm`?`npx`:o,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`}}}},l=`import { defineBasisConfig } from "@funish/basis/config";
3
+
4
+ export default defineBasisConfig(${JSON.stringify(c,null,2)});
5
+ `,d=`${e}/basis.config.ts`;if(await p(d,l,`utf8`),u.success(`Configuration created in ${d}`),!i)try{await m([`--version`],e),u.info(`Git detected`)}catch{u.info(`Git not found`)}return u.success(`Basis initialization completed!`),u.info(`Run 'basis git setup' to setup Git hooks`),!0}const A=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 k(process.cwd(),{force:e.force,skipGitCheck:e[`skip-git-check`],skipInstall:e[`skip-install`]})}catch(e){u.error(`Init failed:`,e),process.exit(1)}}}),j=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=s(e.dir||`.`);try{let{config:n={}}=await r({name:`isbuild`,configFile:`build.config`,cwd:t}),i=(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}});(!i||i.length===0)&&(u.error(`No build entries specified in build.config.`),process.exit(1)),await w({cwd:t,...n,entries:i}),u.success(`Build completed`)}catch(e){u.error(`Build failed:`,e),process.exit(1)}}});async function M(){try{let e=S(`git --exec-path`,{encoding:`utf8`}).trim();if(e){let t=h({LOCAL_GIT_DIRECTORY:s(e,`..`,`..`,`..`)});Object.assign(process.env,t.env),u.debug(`Using system Git from: ${t.gitLocation}`)}}catch{u.debug(`System Git not found, dugite will use embedded Git`)}}M();async function N(e){try{let t=(await m([`diff`,`--cached`,`--name-only`],e)).stdout.trim().split(`
6
+ `).filter(Boolean),n=await m([`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 u.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 u.info(`No staged files to check`),!0;u.start(`Checking ${i.length} staged file(s)`);let a=!1,o=new Set;for(let[e,n]of Object.entries(r)){let r=T(e),s=i.filter(e=>!o.has(e)&&r(e));if(s.length!==0){u.info(`Running ${n} for ${s.length} file(s) matching ${e}`);try{let e=await m([`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)}),S(n,{cwd:t,stdio:`inherit`});let i=await m([`status`,`--porcelain`],t),a=new Set;i.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`)&&(s.includes(i)?a.add(i):r.has(i)||a.add(i))}),a.size>0&&(await m([`add`,...Array.from(a)],t),u.info(`Re-staged ${a.size} file(s) after formatting`)),s.forEach(e=>o.add(e))}catch(t){a=!0,u.error(`Staged check failed for pattern '${e}':`,t)}}}return a?(u.error(`Some staged files checks failed`),!1):(u.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,o=r?.minLength||10,c=r?.scopeRequired||!1,l=r?.allowedScopes||[],f;try{let e=s(t,`.git/COMMIT_EDITMSG`);try{f=(await d(e)).toString(`utf8`)}catch{f=(await m([`log`,`-1`,`--pretty=%B`],t)).stdout.trim()}}catch(e){return u.error(`Failed to read commit message:`,e),!1}let p=[],h=I(f);if(!h)return u.error(`Invalid commit format. Expected: type(scope): subject`),!1;i.includes(h.type)||p.push(`Invalid type '${h.type}'. Allowed: ${i.join(`, `)}`);let g=f.split(`
11
+ `)[0];return g.length>a&&p.push(`Header too long (${g.length} chars). Max: ${a}`),g.length<o&&p.push(`Header too short (${g.length} chars). Min: ${o}`),c&&!h.scope&&p.push(`Scope is required`),h.scope&&l.length>0&&!l.includes(h.scope)&&p.push(`Invalid scope '${h.scope}'. Allowed: ${l.join(`, `)}`),p.length>0?(u.error(`Invalid commit message:`),p.forEach(e=>u.error(` ${e}`)),!1):(u.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 u.warn(`No Git hooks configured`),!0;let i=s(t,`.git/hooks`);try{for(let[e,t]of Object.entries(r))await p(s(i,e),`#!/bin/sh\n${t}\n`,{mode:493}),u.success(`Created ${e} hook`);return!0}catch(e){return u.error(`Failed to setup Git hooks:`,e),!1}}async function z(e=process.cwd()){return u.start(`Setting up Git configuration`),await R(e)?(u.success(`Git setup completed`),!0):!1}const B=c({meta:{name:`git`,description:`Git operations`},async run({rawArgs:e}){let t=e[0];if(!t){u.info(`Available subcommands: staged, lint-commit, setup`),u.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 m(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){u.error(`Git operation failed:`,e),process.exit(1)}}}}),V=c({meta:{name:`run`,description:`Run scripts or files`},async run({rawArgs:t}){t.length===0&&(u.error(`Please specify a script name or file path`),process.exit(1));let[n,...r]=t,i=process.cwd(),{config:a}=await e(),o=a.run?.config,c=s(i,n);if(E(c))try{let e=ee(i,o),n=e.esmResolve(c);process.argv=[process.argv[0],n,...t.slice(1)],await e.import(n);return}catch(e){u.error(`Failed to run file:`),u.error(` ${String(e)}`),process.exit(1)}try{await x(n,{cwd:i,args:r})}catch(e){u.error(`Failed to run script "${n}":`),u.error(` ${String(e)}`),process.exit(1)}}});function H(e,t,n){if(t.version){if(D.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(!D.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=D.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`)?D.inc(e,a,i):D.inc(e,a);if(!o)throw Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return o}const U=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:t}){try{let{config:n}=await e(),r={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)?r[e]=!0:r.version=e}let s=process.cwd(),c=await i(s),l=c.version;if(!l)throw Error(`No version found in package.json`);let d=H(l,r,n.version||{});if(!r.allowSameVersion&&d===l)throw Error(`Version unchanged: ${l}. Use --allow-same-version to allow this.`);await o(await a(s),{...c,version:d}),u.success(`Version updated: ${l} → ${d}`)}catch(e){u.error(`Version update failed:`,e),process.exit(1)}}});async function W(e,t){let n=process.cwd(),r=await i(n),a=r.version,o=r.name;if(!o)throw Error(`Package name is required in package.json`);if(!a)throw Error(`Package version is required in package.json`);let s=(await v(n))?.name||`npm`,c={tag:`latest`,access:`public`,...t.npm},l=e.tag;if(!l&&a&&a.includes(`-`)){let e=a.match(/-(\w+)\.\d+$/);e&&(l=e[1])}l=l||c.tag||`latest`;let d=C(s,[`publish`,...(t=>{let n=[];e.tarball&&n.push(e.tarball),n.push(`--tag`,t);let r=e.access||c.access;return r&&n.push(`--access`,r),e.dryRun&&n.push(`--dry-run`),e.otp&&n.push(`--otp`,e.otp),n})(l)],{stdio:`inherit`,shell:!0});if(d.status!==0){u.error(`Publish failed with exit code ${d.status}`);return}let f=c.additionalTag;if(!e.dryRun&&f&&f!==l){let e=C(`npm`,[`dist-tag`,`add`,`${o}@${a}`,f],{cwd:n,stdio:`inherit`,shell:!0});if(e.status!==0){u.error(`Failed to add dist-tag with exit code ${e.status}`);return}}else f&&u.info(`Skipping dist-tag ${f} (same as publish tag ${l})`)}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 m([`add`,`package.json`],n),await m([`commit`,`-m`,a],n),await m([`tag`,i,...t?.signTag?[`--sign`]:[]],n),t?.push&&(await m([`push`],n),await m([`push`,`--tags`],n))}const K=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: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||{}),u.success(`Package published successfully`),t.git&&n.publish?.git){u.info(`Creating git tag and commit...`);let e=(await i(process.cwd())).version;e&&(await G(e,n.publish.git),u.success(`Git operations completed`))}}catch(e){u.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,r=!1){let{config:o}=await e({overrides:n?{audit:{dependencies:n}}:void 0}),s=o.audit?.dependencies||{};u.start(`Auditing dependencies...`);let c=!1;if(s.blocked&&s.blocked.length>0)try{let e=await i(t),n={...e.dependencies,...e.devDependencies},r=Object.keys(n).filter(e=>s.blocked?.includes(e));r.length>0&&(u.error(`Found ${r.length} blocked package(s): ${r.join(`, `)}`),c=!0)}catch(e){u.error(`Failed to check blocked packages:`,e),c=!0}if(s.outdated)try{let e=(await v(t))?.name||`npm`,n=q[e];n.outdated?C(e,n.outdated,{cwd:t,stdio:`inherit`,shell:!0}).status!==0&&u.warn(`Some dependencies are outdated`):u.info(`Skipping outdated check for ${e}`)}catch(e){u.error(`Failed to check outdated dependencies:`,e),c=!0}if(s.security)try{let e=(await v(t))?.name||`npm`,n=q[e];n.audit?C(e,n.audit,{cwd:t,stdio:`inherit`,shell:!0}).status!==0&&(c=!0):u.info(`Skipping security audit for ${e}`)}catch(e){u.error(`Failed to check security vulnerabilities:`,e),c=!0}if(s.licenses&&(s.licenses.allowed||s.licenses.blocked))try{let e=await a(t),n=await Y(t),r=[];for(let t of n)try{let n=await i(t);if(!n.name||t===e)continue;if(n.license){let e=Array.isArray(n.license)?n.license.join(`, `):n.license;if(s.licenses.blocked&&s.licenses.blocked.some(t=>e.includes(t))){r.push(`${n.name}: ${e}`);continue}s.licenses.allowed&&s.licenses.allowed.length>0&&(s.licenses.allowed.some(t=>e.includes(t))||r.push(`${n.name}: ${e}`))}}catch{}r.length>0&&(u.error(`Packages with invalid licenses:`),r.forEach(e=>u.error(` ${e}`)),c=!0)}catch(e){u.error(`Failed to check licenses:`,e),c=!0}return c||u.success(`Dependencies audit passed`),!c}async function Y(e){try{return await O([`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||{};u.start(`Auditing project structure...`);let a=!1;if(i.required&&i.required.length>0){let e=[];for(let n of i.required)try{await f(s(t,n))}catch{n.includes(`*`)||n.includes(`?`)?(await O([n],{cwd:t})).length===0&&e.push(n):e.push(n)}e.length>0&&(u.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 O([e.pattern],{cwd:t}),r=new RegExp(e.rule),i=n.filter(e=>!r.test(e));i.length>0&&(u.error(`${e.message}: ${i.slice(0,5).join(`, `)}${i.length>5?`...`:``}`),a=!0)}catch(t){u.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 O([e.pattern],{cwd:t}),r=new RegExp(e.rule),i=n.filter(e=>!r.test(e));i.length>0&&(u.error(`${e.message}: ${i.slice(0,5).join(`, `)}${i.length>5?`...`:``}`),a=!0)}catch(t){u.error(`Failed to check directory naming rule: ${e.pattern}`,t),a=!0}return a||u.success(`Structure audit passed`),!a}async function Z(t=process.cwd(),n=!1){let{config:r}=await e(),i=r.audit||{};u.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?(u.success(`All audits passed`),!0):(u.error(`${a.length} audit(s) failed`),!1)}const Q=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 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||(u.error(`Some audits failed`),process.exit(1))}}),te=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&&(u.error(`Please specify at least one package name`),u.info(`Example: basis add lodash`),process.exit(1));let n=t.filter(e=>!e.startsWith(`-`));n.length===0&&(u.error(`Please specify at least one package name`),process.exit(1));try{e.dev?(await _(n,{cwd:process.cwd()}),u.success(`Added ${n.join(`, `)} as dev dependencies`)):(await g(n,{cwd:process.cwd()}),u.success(`Added ${n.join(`, `)} as dependencies`))}catch(e){u.error(`Add packages failed:`,e),process.exit(1)}}}),ne=c({meta:{name:`remove`,description:`Remove dependencies`},async run({rawArgs:e}){e.length===0&&(u.error(`Please specify at least one package name`),u.info(`Example: basis remove lodash`),process.exit(1));let t=e.filter(e=>!e.startsWith(`-`));t.length===0&&(u.error(`Please specify at least one package name`),process.exit(1));try{await b(t,{cwd:process.cwd()}),u.success(`Removed ${t.join(`, `)}`)}catch(e){u.error(`Remove packages failed:`,e),process.exit(1)}}}),re=c({meta:{name:`dlx`,description:`Execute package without installation`},async run({rawArgs:e}){try{e.length===0&&(u.error(`Please specify a package to run`),process.exit(1));let[t,...n]=e;await y(t,{args:n,cwd:process.cwd()}),u.success(`Dlx completed`)}catch(e){u.error(`Dlx failed:`,e),process.exit(1)}}}),$=await i(import.meta.url);l(c({meta:{name:`basis`,description:$.description,version:$.version},subCommands:{init:A,lint:t,fmt:n,build:j,git:B,run:V,version:U,publish:K,audit:Q,add:te,remove:ne,dlx:re}}));export{};
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import"../_chunks/config-lvw40IpZ.mjs";import"../_chunks/run-D8ZiNeaU.mjs";import{t as e}from"../_chunks/fmt-9Yi9STzz.mjs";import{runMain as t}from"citty";t(e);export{};
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import"../_chunks/config-lvw40IpZ.mjs";import"../_chunks/run-D8ZiNeaU.mjs";import{t as e}from"../_chunks/lint-3A6_NhRY.mjs";import{runMain as t}from"citty";t(e);export{};