@funish/basis 0.1.3 → 0.2.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 (80) hide show
  1. package/README.md +131 -427
  2. package/dist/_chunks/config.mjs +1 -0
  3. package/dist/_chunks/types.d.mts +194 -0
  4. package/dist/cli.d.mts +1 -1
  5. package/dist/cli.mjs +8 -1
  6. package/dist/commands/add.d.mts +2 -0
  7. package/dist/commands/add.mjs +1 -0
  8. package/dist/commands/audit.d.mts +2 -0
  9. package/dist/commands/audit.mjs +1 -0
  10. package/dist/commands/build.d.mts +2 -0
  11. package/dist/commands/build.mjs +1 -0
  12. package/dist/commands/check.d.mts +2 -0
  13. package/dist/commands/check.mjs +1 -0
  14. package/dist/commands/dlx.d.mts +2 -0
  15. package/dist/commands/dlx.mjs +1 -0
  16. package/dist/commands/fmt.d.mts +2 -0
  17. package/dist/commands/fmt.mjs +1 -0
  18. package/dist/commands/git.d.mts +2 -0
  19. package/dist/commands/git.mjs +1 -0
  20. package/dist/commands/init.d.mts +2 -0
  21. package/dist/commands/init.mjs +1 -0
  22. package/dist/commands/lint.d.mts +2 -0
  23. package/dist/commands/lint.mjs +1 -0
  24. package/dist/commands/publish.d.mts +2 -0
  25. package/dist/commands/publish.mjs +1 -0
  26. package/dist/commands/remove.d.mts +2 -0
  27. package/dist/commands/remove.mjs +1 -0
  28. package/dist/commands/run.d.mts +2 -0
  29. package/dist/commands/run.mjs +1 -0
  30. package/dist/commands/version.d.mts +2 -0
  31. package/dist/commands/version.mjs +1 -0
  32. package/dist/config.d.mts +24 -1
  33. package/dist/config.mjs +1 -1
  34. package/dist/index.d.mts +2 -178
  35. package/dist/index.mjs +1 -1
  36. package/package.json +69 -55
  37. package/dist/chunks/add.cjs +0 -1
  38. package/dist/chunks/add.mjs +0 -1
  39. package/dist/chunks/config.cjs +0 -1
  40. package/dist/chunks/config.mjs +0 -1
  41. package/dist/chunks/git.cjs +0 -1
  42. package/dist/chunks/git.mjs +0 -1
  43. package/dist/chunks/init.cjs +0 -1
  44. package/dist/chunks/init.mjs +0 -1
  45. package/dist/chunks/install.cjs +0 -1
  46. package/dist/chunks/install.mjs +0 -1
  47. package/dist/chunks/lint.cjs +0 -1
  48. package/dist/chunks/lint.mjs +0 -1
  49. package/dist/chunks/publish.cjs +0 -1
  50. package/dist/chunks/publish.mjs +0 -1
  51. package/dist/chunks/remove.cjs +0 -1
  52. package/dist/chunks/remove.mjs +0 -1
  53. package/dist/chunks/run.cjs +0 -1
  54. package/dist/chunks/run.mjs +0 -1
  55. package/dist/chunks/version.cjs +0 -1
  56. package/dist/chunks/version.mjs +0 -1
  57. package/dist/cli.cjs +0 -2
  58. package/dist/cli.d.cts +0 -1
  59. package/dist/cli.d.ts +0 -1
  60. package/dist/config.cjs +0 -1
  61. package/dist/config.d.cts +0 -1
  62. package/dist/config.d.ts +0 -1
  63. package/dist/index.cjs +0 -1
  64. package/dist/index.d.cts +0 -178
  65. package/dist/index.d.ts +0 -178
  66. package/dist/shared/basis.4m3-erzm.mjs +0 -1
  67. package/dist/shared/basis.5if__eE1.mjs +0 -8
  68. package/dist/shared/basis.Bqr6BGbD.cjs +0 -1
  69. package/dist/shared/basis.BrlVPuDi.mjs +0 -1
  70. package/dist/shared/basis.Bz4YLlJG.cjs +0 -1
  71. package/dist/shared/basis.CGkMo_WB.cjs +0 -3
  72. package/dist/shared/basis.CYJFGkEy.mjs +0 -1
  73. package/dist/shared/basis.Cc1QkX4i.mjs +0 -3
  74. package/dist/shared/basis.CyWSd-ys.mjs +0 -10
  75. package/dist/shared/basis.D3fInv-P.cjs +0 -1
  76. package/dist/shared/basis.DoHZYvYm.d.cts +0 -275
  77. package/dist/shared/basis.DoHZYvYm.d.mts +0 -275
  78. package/dist/shared/basis.DoHZYvYm.d.ts +0 -275
  79. package/dist/shared/basis.GHY7v-ns.cjs +0 -10
  80. package/dist/shared/basis.iEUClefn.cjs +0 -8
@@ -0,0 +1,194 @@
1
+ import { GitConfig } from "pkg-types";
2
+ import { JitiOptions } from "jiti";
3
+
4
+ //#region src/types.d.ts
5
+ interface BasisConfig {
6
+ lint?: LintConfig;
7
+ fmt?: FmtConfig;
8
+ git?: GitConfig$1;
9
+ run?: RunConfig;
10
+ audit?: AuditConfig;
11
+ version?: VersionConfig;
12
+ publish?: PublishConfig;
13
+ }
14
+ /**
15
+ * Lint command configuration
16
+ */
17
+ interface LintConfig {
18
+ /** Linter configuration options (passed as command line args) */
19
+ config?: string[];
20
+ }
21
+ /**
22
+ * Format command configuration
23
+ */
24
+ interface FmtConfig {
25
+ /** Formatter configuration options (passed as command line args) */
26
+ config?: string[];
27
+ }
28
+ /**
29
+ * Staged files configuration (lint-staged style)
30
+ */
31
+ interface StagedConfig {
32
+ /** Commands to run on staged files */
33
+ rules?: Record<string, string>;
34
+ }
35
+ /**
36
+ * Git command configuration
37
+ */
38
+ interface GitConfig$1 {
39
+ /** Git hooks */
40
+ hooks?: Partial<Record<ValidGitHook, string>>;
41
+ /** Git configuration */
42
+ config?: GitConfig;
43
+ /** Commit message validation */
44
+ commitMsg?: CommitMsgConfig;
45
+ /** Staged files check */
46
+ staged?: StagedConfig;
47
+ }
48
+ /**
49
+ * Run command configuration
50
+ */
51
+ interface RunConfig {
52
+ /** Runtime configuration options */
53
+ config?: JitiOptions;
54
+ }
55
+ /**
56
+ * Audit command configuration
57
+ */
58
+ interface AuditConfig {
59
+ /** Dependencies audit */
60
+ dependencies?: {
61
+ /** Check for outdated dependencies */outdated?: boolean; /** Check for security vulnerabilities */
62
+ security?: boolean; /** License compliance check */
63
+ licenses?: {
64
+ /** Allowed licenses */allowed?: string[]; /** Blocked licenses */
65
+ blocked?: string[];
66
+ }; /** Blocked packages */
67
+ blocked?: string[];
68
+ };
69
+ /** Structure audit */
70
+ structure?: {
71
+ /** Required files/directories */required?: string[]; /** File naming conventions */
72
+ files?: Array<{
73
+ pattern: string;
74
+ rule: string;
75
+ message: string;
76
+ }>; /** Directory naming conventions */
77
+ dirs?: Array<{
78
+ pattern: string;
79
+ rule: string;
80
+ message: string;
81
+ }>;
82
+ };
83
+ }
84
+ /**
85
+ * Version command configuration
86
+ */
87
+ interface VersionConfig {
88
+ /** Prerelease identifier (default: "edge") */
89
+ preid?: string;
90
+ }
91
+ /**
92
+ * Publish command configuration
93
+ */
94
+ interface PublishConfig {
95
+ /** NPM publish configuration */
96
+ npm?: {
97
+ /** Default publish tag (default: "latest") */tag?: string; /** Additional tag to also publish to (e.g., "edge") */
98
+ additionalTag?: string; /** Package access level (default: "public") */
99
+ access?: "public" | "restricted";
100
+ };
101
+ /** Git operations configuration */
102
+ git?: {
103
+ /** Git tag prefix (default: "v") */tagPrefix?: string; /** Commit message generator */
104
+ message?: (version: string) => string; /** Auto push to remote */
105
+ push?: boolean; /** Sign git tag */
106
+ signTag?: boolean;
107
+ };
108
+ }
109
+ /**
110
+ * Commit message validation configuration
111
+ */
112
+ interface CommitMsgConfig {
113
+ types?: string[];
114
+ maxLength?: number;
115
+ minLength?: number;
116
+ scopeRequired?: boolean;
117
+ allowedScopes?: string[];
118
+ }
119
+ /**
120
+ * Parsed commit message
121
+ */
122
+ interface CommitMessage {
123
+ type: string;
124
+ scope?: string;
125
+ description: string;
126
+ body?: string;
127
+ footer?: string;
128
+ isBreaking: boolean;
129
+ }
130
+ declare const VALID_GIT_HOOKS: readonly ["applypatch-msg", "pre-applypatch", "post-applypatch", "pre-commit", "pre-merge-commit", "prepare-commit-msg", "commit-msg", "post-commit", "pre-rebase", "post-checkout", "post-merge", "pre-push", "pre-receive", "update", "proc-receive", "post-receive", "post-update", "reference-transaction", "push-to-checkout", "pre-auto-gc", "post-rewrite", "sendemail-validate", "fsmonitor-watchman", "p4-changelist", "p4-prepare-changelist", "p4-post-changelist", "p4-pre-submit", "post-index-change"];
131
+ type ValidGitHook = (typeof VALID_GIT_HOOKS)[number];
132
+ /**
133
+ * Init command options
134
+ */
135
+ interface InitOptions {
136
+ force?: boolean;
137
+ skipGitCheck?: boolean;
138
+ skipInstall?: boolean;
139
+ }
140
+ /**
141
+ * Version command options
142
+ */
143
+ interface VersionOptions {
144
+ /** Version number or increment type */
145
+ version?: string;
146
+ /** Prerelease identifier */
147
+ preid?: string;
148
+ /** Bump type */
149
+ major?: boolean;
150
+ minor?: boolean;
151
+ patch?: boolean;
152
+ premajor?: boolean;
153
+ preminor?: boolean;
154
+ prepatch?: boolean;
155
+ prerelease?: boolean;
156
+ fromGit?: boolean;
157
+ /** Commit message */
158
+ message?: string;
159
+ /** Create git tag */
160
+ tag?: boolean;
161
+ /** Allow same version */
162
+ allowSameVersion?: boolean;
163
+ /** Skip commit hooks */
164
+ noCommitHooks?: boolean;
165
+ /** Sign git tag */
166
+ signGitTag?: boolean;
167
+ /** Workspace mode */
168
+ workspace?: string[];
169
+ workspaces?: boolean;
170
+ noWorkspacesUpdate?: boolean;
171
+ includeWorkspaceRoot?: boolean;
172
+ }
173
+ /**
174
+ * Publish command options
175
+ */
176
+ interface PublishOptions {
177
+ /** Tarball or directory to publish */
178
+ tarball?: string;
179
+ /**
180
+ * Publish tag (overrides version-based tag detection)
181
+ * Priority: options.tag > version prerelease > config.tag
182
+ */
183
+ tag?: string;
184
+ /** Also create git tag and commit */
185
+ git?: boolean;
186
+ /** Package access level */
187
+ access?: "public" | "restricted";
188
+ /** Dry run mode */
189
+ dryRun?: boolean;
190
+ /** One-time password for 2FA */
191
+ otp?: string;
192
+ }
193
+ //#endregion
194
+ 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 };
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
-
1
+ export { };
package/dist/cli.mjs CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import{defineCommand as n,runMain as o}from"citty";import{consola as r}from"consola";import{readPackageJSON as a}from"pkg-types";async function m(){const i=await a(import.meta.url),e=n({meta:{name:"basis",version:i.version||"",description:i.description||""},subCommands:{init:()=>import("./chunks/init.mjs").then(t=>t.default),config:()=>import("./chunks/config.mjs").then(t=>t.default),lint:()=>import("./chunks/lint.mjs").then(t=>t.lint),git:()=>import("./chunks/git.mjs").then(t=>t.git),install:()=>import("./chunks/install.mjs").then(t=>t.default),i:()=>import("./chunks/install.mjs").then(t=>t.default),add:()=>import("./chunks/add.mjs").then(t=>t.default),remove:()=>import("./chunks/remove.mjs").then(t=>t.default),rm:()=>import("./chunks/remove.mjs").then(t=>t.default),uninstall:()=>import("./chunks/remove.mjs").then(t=>t.default),run:()=>import("./chunks/run.mjs").then(t=>t.default),version:()=>import("./chunks/version.mjs").then(t=>t.default),publish:()=>import("./chunks/publish.mjs").then(t=>t.default)}});await o(e)}m().catch(r.error);
2
+ import{r as e}from"./_chunks/config.mjs";import{defineCommand as t,runMain as n}from"citty";import{consola as r}from"consola";import{readPackageJSON as i,resolvePackageJSON as a,writePackageJSON as o}from"pkg-types";import{readFile as s,stat as c,writeFile as l}from"node:fs/promises";import{exec as u}from"dugite";import{loadConfig as d}from"c12";import{addDependency as f,addDevDependency as p,detectPackageManager as m,dlx as h,removeDependency as g,runScript as _}from"nypm";import{dirname as v,resolve as y}from"pathe";import{build as b}from"@funish/build";import{execSync as x}from"node:child_process";import S from"picomatch";import{createJiti as C}from"jiti";import w from"semver";import{existsSync as ee}from"node:fs";import{glob as T}from"tinyglobby";async function E(e=process.cwd(),t={}){let{force:n=!1,skipGitCheck:i=!1}=t;r.start(`Initializing basis configuration`);let a=(await d({cwd:e,name:`basis`}))._configFile;if(a&&!n)return r.error(`Configuration file already exists: ${a}`),r.info(`Use --force to overwrite.`),!1;let o=(await m(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 --fix`,"*.{json,md,yml,yaml}":`basis fmt --write`}}}},f=`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,f,`utf8`),r.success(`Configuration created in ${p}`),!i)try{await u([`--version`],e),r.info(`Git detected`)}catch{r.info(`Git not found`)}return r.success(`Basis initialization completed!`),r.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){r.error(`Init failed:`,e),process.exit(1)}}}),O=t({meta:{name:`lint`,description:`Lint code`},async run({rawArgs:t}){let n=process.cwd(),{config:i}=await e({cwd:n}),a=[...i.lint?.config||[],...t];try{await h(`oxlint`,{args:a,cwd:n}),r.success(`Linting completed`)}catch(e){r.error(`Linting failed:`,e),process.exit(1)}}}),k=t({meta:{name:`fmt`,description:`Format code`},async run({rawArgs:t}){let n=process.cwd(),{config:i}=await e({cwd:n}),a=[...i.fmt?.config||[],...t];try{await h(`oxfmt`,{args:a,cwd:n}),r.success(`Formatting completed`)}catch(e){r.error(`Formatting failed:`,e),process.exit(1)}}}),A=t({meta:{name:`check`,description:`Type check code`},async run({rawArgs:e}){try{await h(`vue-tsc`,{args:[`--noEmit`,...e],cwd:process.cwd()}),r.success(`Type checking completed`)}catch(e){r.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 d({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)&&(r.error(`No build entries specified in build.config.`),process.exit(1)),await b({cwd:t,...n,entries:i}),r.success(`Build completed`)}catch(e){r.error(`Build failed:`,e),process.exit(1)}}});async function M(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 N(t=process.cwd()){let{config:n}=await e({cwd:t}),i=n.git?.staged?.rules||{};if(Object.keys(i).length===0)return r.warn(`No staged rules configured. Add git.staged.rules to your basis.config.ts`),!0;let a=await M(t);if(a.length===0)return r.info(`No staged files to check`),!0;r.start(`Checking ${a.length} staged file(s)`);let o=!1,s=new Set;for(let[e,n]of Object.entries(i)){let i=a.filter(t=>!s.has(t)&&S(t,e));if(i.length!==0){r.info(`Running ${n} for ${i.length} file(s) matching ${e}`);try{let[e,...r]=n.split(` `);x(`${e} ${r.join(` `)}`,{cwd:t,stdio:`inherit`});let a=[];for(let e of i)try{await c(y(t,e)),a.push(e)}catch{}a.length>0&&await u([`add`,...a],t),i.forEach(e=>s.add(e))}catch(t){o=!0,r.error(`Staged check failed for pattern '${e}':`,t)}}}return o?(r.error(`Some staged files checks failed`),!1):(r.success(`Staged files check passed`),!0)}const P=[`feat`,`fix`,`docs`,`style`,`refactor`,`perf`,`test`,`build`,`ci`,`chore`,`revert`];function F(e){let t=e.trim().split(`
8
+ `)[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 I(t=process.cwd()){let{config:n}=await e({cwd:t}),i=n.git?.commitMsg,a=i?.types||P,o=i?.maxLength||72,c=i?.minLength||10,l=i?.scopeRequired||!1,d=i?.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 r.error(`Failed to read commit message:`,e),!1}let p=[],m=F(f);if(!m)return r.error(`Invalid commit format. Expected: type(scope): subject`),!1;a.includes(m.type)||p.push(`Invalid type '${m.type}'. Allowed: ${a.join(`, `)}`);let h=f.split(`
9
+ `)[0];return h.length>o&&p.push(`Header too long (${h.length} chars). Max: ${o}`),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?(r.error(`Invalid commit message:`),p.forEach(e=>r.error(` ${e}`)),!1):(r.success(`Commit message validation passed`),!0)}async function L(t=process.cwd()){let{config:n}=await e({cwd:t}),i=n.git?.hooks;if(!i||Object.keys(i).length===0)return r.warn(`No Git hooks configured`),!0;let a=y(t,`.git/hooks`);try{for(let[e,t]of Object.entries(i))await l(y(a,e),`#!/bin/sh\n${t}\n`,{mode:493}),r.success(`Created ${e} hook`);return!0}catch(e){return r.error(`Failed to setup Git hooks:`,e),!1}}async function R(e=process.cwd()){return r.start(`Setting up Git configuration`),await L(e)?(r.success(`Git setup completed`),!0):!1}const z=t({meta:{name:`git`,description:`Git operations`},subCommands:{staged:t({meta:{name:`staged`,description:`Check staged files`},async run(){await N()||process.exit(1)}}),"lint-commit":t({meta:{name:`lint-commit`,description:`Validate commit message`},async run(){await I()||process.exit(1)}}),setup:t({meta:{name:`setup`,description:`Setup Git hooks and configuration`},async run(){await R()||process.exit(1)}})},async run({rawArgs:e}){if(e.length===0){r.info(`Available subcommands: staged, lint-commit, setup`),r.info(`Git passthrough mode: basis git <git-command>`);return}let t=[`staged`,`lint-commit`,`setup`],n=e[0];if(!t.includes(n))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){r.error(`Git operation failed:`,e),process.exit(1)}}}),B=t({meta:{name:`run`,description:`Run scripts or files`},async run({rawArgs:t}){t.length===0&&(r.error(`Please specify a script name or file path`),process.exit(1));let[n,...i]=t,a=process.cwd(),{config:o}=await e({cwd:a}),s=o.run?.config;try{await _(n,{cwd:a,args:i});return}catch(e){try{await C(a,s).import(n);return}catch(t){r.error(`Run failed:`),r.error(` runScript error: ${String(e)}`),r.error(` jiti error: ${String(t)}`),r.info(`\nTried to run "${n}" as both a package.json script and a file, but both failed.`),process.exit(1)}}}});function V(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 H=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 i(c),u=l.version;if(!u)throw Error(`No version found in package.json`);let d=V(u,s,n.version||{});if(!s.allowSameVersion&&d===u)throw Error(`Version unchanged: ${u}. Use --allow-same-version to allow this.`);await o(await a(c),{...l,version:d}),r.success(`Version updated: ${u} → ${d}`)}catch(e){r.error(`Version update failed:`,e),process.exit(1)}}});async function U(e,t){let n=process.cwd(),a=await i(n),o=a.version,s=a.name;if(!s)throw Error(`Package name is required in package.json`);if(!o)throw Error(`Package version is required in package.json`);let c=(await m(n))?.name||`npm`,l={tag:`latest`,access:`public`,...t.npm},u=e.tag;if(!u&&o&&o.includes(`-`)){let e=o.match(/-(\w+)\.\d+$/);e&&(u=e[1])}u=u||l.tag||`latest`,x(`${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?x(`npm dist-tag add ${s}@${o} ${d}`,{cwd:n,stdio:`inherit`}):d&&r.info(`Skipping dist-tag ${d} (same as publish tag ${u})`)}async function W(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 G=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 n=process.cwd(),a;for(;n!==v(n);){let e=y(n,`basis.config.ts`);if(ee(e)){a=e;break}n=v(n)}let{config:o}=await e({cwd:a?v(a):process.cwd()});if(await U({tag:t.tag,git:t.git,access:t.access||void 0,dryRun:t[`dry-run`],otp:t.otp},o.publish||{}),r.success(`Package published successfully`),t.git&&o.publish?.git){r.info(`Creating git tag and commit...`);let e=(await i(process.cwd())).version;e&&(await W(e,o.publish.git),r.success(`Git operations completed`))}}catch(e){r.error(`Publish failed:`,e),process.exit(1)}}}),K={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 q(t=process.cwd(),n,o=!1){let{config:s}=await e({cwd:t,overrides:n?{audit:{dependencies:n}}:void 0}),c=s.audit?.dependencies||{};r.start(`Auditing dependencies...`);let l=!1;if(c.blocked&&c.blocked.length>0)try{let e=await i(t),n={...e.dependencies,...e.devDependencies},a=Object.keys(n).filter(e=>c.blocked?.includes(e));a.length>0&&(r.error(`Found ${a.length} blocked package(s): ${a.join(`, `)}`),l=!0)}catch(e){r.error(`Failed to check blocked packages:`,e),l=!0}if(c.outdated)try{let e=(await m(t))?.name||`npm`,n=K[e];if(!n.outdated)r.info(`Skipping outdated check for ${e}`);else try{x(`${e} ${n.outdated.join(` `)}`,{cwd:t,stdio:`inherit`})}catch{r.warn(`Some dependencies are outdated`)}}catch(e){r.error(`Failed to check outdated dependencies:`,e),l=!0}if(c.security)try{let e=(await m(t))?.name||`npm`,n=K[e];if(!n.audit)r.info(`Skipping security audit for ${e}`);else try{x(`${e} ${n.audit.join(` `)}`,{cwd:t,stdio:`inherit`})}catch{l=!0}}catch(e){r.error(`Failed to check security vulnerabilities:`,e),l=!0}if(c.licenses&&(c.licenses.allowed||c.licenses.blocked))try{let e=await a(t),n=await J(t),o=[];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(c.licenses.blocked&&c.licenses.blocked.some(t=>e.includes(t))){o.push(`${n.name}: ${e}`);continue}c.licenses.allowed&&c.licenses.allowed.length>0&&(c.licenses.allowed.some(t=>e.includes(t))||o.push(`${n.name}: ${e}`))}}catch{}o.length>0&&(r.error(`Packages with invalid licenses:`),o.forEach(e=>r.error(` ${e}`)),l=!0)}catch(e){r.error(`Failed to check licenses:`,e),l=!0}return l||r.success(`Dependencies audit passed`),!l}async function J(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 Y(t=process.cwd(),n){let{config:i}=await e({cwd:t,overrides:n?{audit:{structure:n}}:void 0}),a=i.audit?.structure||{};r.start(`Auditing project structure...`);let o=!1;if(a.required&&a.required.length>0){let e=[];for(let n of a.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&&(r.error(`Missing required file(s)/director(ies): ${e.join(`, `)}`),o=!0)}if(a.files&&a.files.length>0)for(let e of a.files)try{let n=await T([e.pattern],{cwd:t}),i=new RegExp(e.rule),a=n.filter(e=>!i.test(e));a.length>0&&(r.error(`${e.message}: ${a.slice(0,5).join(`, `)}${a.length>5?`...`:``}`),o=!0)}catch(t){r.error(`Failed to check file naming rule: ${e.pattern}`,t),o=!0}if(a.dirs&&a.dirs.length>0)for(let e of a.dirs)try{let n=await T([e.pattern],{cwd:t}),i=new RegExp(e.rule),a=n.filter(e=>!i.test(e));a.length>0&&(r.error(`${e.message}: ${a.slice(0,5).join(`, `)}${a.length>5?`...`:``}`),o=!0)}catch(t){r.error(`Failed to check directory naming rule: ${e.pattern}`,t),o=!0}return o||r.success(`Structure audit passed`),!o}async function X(t=process.cwd(),n=!1){let{config:i}=await e({cwd:t}),a=i.audit||{};r.start(`Running comprehensive project audit...`);let o=(await Promise.allSettled([q(t,a.dependencies,n),Y(t,a.structure)])).filter(e=>e.status===`rejected`||e.status===`fulfilled`&&!e.value);return o.length===0?(r.success(`All audits passed`),!0):(r.error(`${o.length} audit(s) failed`),!1)}const Z=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 X(t,e.fix);else{let r=[];e.dependencies&&r.push(()=>q(t,void 0,e.fix)),e.structure&&r.push(()=>Y(t));for(let e of r)await e()||(n=!1)}n||(r.error(`Some audits failed`),process.exit(1))}}),Q=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&&(r.error(`Please specify at least one package name`),r.info(`Example: basis add lodash`),process.exit(1));let n=t.filter(e=>!e.startsWith(`-`));n.length===0&&(r.error(`Please specify at least one package name`),process.exit(1));try{e.dev?(await p(n,{cwd:process.cwd()}),r.success(`Added ${n.join(`, `)} as dev dependencies`)):(await f(n,{cwd:process.cwd()}),r.success(`Added ${n.join(`, `)} as dependencies`))}catch(e){r.error(`Add packages failed:`,e),process.exit(1)}}}),te=t({meta:{name:`remove`,description:`Remove dependencies`},async run({rawArgs:e}){e.length===0&&(r.error(`Please specify at least one package name`),r.info(`Example: basis remove lodash`),process.exit(1));let t=e.filter(e=>!e.startsWith(`-`));t.length===0&&(r.error(`Please specify at least one package name`),process.exit(1));try{await g(t,{cwd:process.cwd()}),r.success(`Removed ${t.join(`, `)}`)}catch(e){r.error(`Remove packages failed:`,e),process.exit(1)}}}),ne=t({meta:{name:`dlx`,description:`Execute package without installation`},async run({rawArgs:e}){try{e.length===0&&(r.error(`Please specify a package to run`),process.exit(1));let[t,...n]=e;await h(t,{args:n,cwd:process.cwd()}),r.success(`Dlx completed`)}catch(e){r.error(`Dlx failed:`,e),process.exit(1)}}}),$=await i(import.meta.url);n(t({meta:{name:`basis`,description:$.description,version:$.version},subCommands:{init:D,lint:O,fmt:k,check:A,build:j,git:z,run:B,version:H,publish:G,audit:Z,add:Q,remove:te,dlx:ne}})).catch(e=>{r.error(e),process.exit(1)});export{};
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const addCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{addDependency as n,addDevDependency as r}from"nypm";export const addCommand=e({meta:{name:`add`,description:`Add dependencies`},args:{dev:{type:`boolean`,description:`Add as dev dependency`,alias:`D`}},async run({args:e,rawArgs:i}){i.length===0&&(t.error(`Please specify at least one package name`),t.info(`Example: basis add lodash`),process.exit(1));let a=i.filter(e=>!e.startsWith(`-`));a.length===0&&(t.error(`Please specify at least one package name`),process.exit(1));try{e.dev?(await r(a,{cwd:process.cwd()}),t.success(`Added ${a.join(`, `)} as dev dependencies`)):(await n(a,{cwd:process.cwd()}),t.success(`Added ${a.join(`, `)} as dependencies`))}catch(e){t.error(`Add packages failed:`,e),process.exit(1)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const auditCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{auditDependencies as n,auditStructure as r,auditAll as i}from"../modules/audit.mjs";export const auditCommand=e({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 a=process.cwd(),o=!0;if(!e.dependencies&&!e.structure)o=await i(a,e.fix);else{let t=[];e.dependencies&&t.push(()=>n(a,void 0,e.fix)),e.structure&&t.push(()=>r(a));for(let e of t)await e()||(o=!1)}o||(t.error(`Some audits failed`),process.exit(1))}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const buildCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{resolve as n}from"pathe";import{build as r}from"@funish/build";import{loadConfig as i}from"c12";export const buildCommand=e({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 a=n(e.dir||`.`);try{let{config:n={}}=await i({name:`isbuild`,configFile:`build.config`,cwd:a}),o=(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}});(!o||o.length===0)&&(t.error(`No build entries specified in build.config.`),process.exit(1)),await r({cwd:a,...n,entries:o}),t.success(`Build completed`)}catch(e){t.error(`Build failed:`,e),process.exit(1)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const checkCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
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)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const dlxCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{dlx as n}from"nypm";export const dlxCommand=e({meta:{name:`dlx`,description:`Execute package without installation`},async run({rawArgs:e}){try{e.length===0&&(t.error(`Please specify a package to run`),process.exit(1));let[r,...i]=e;await n(r,{args:i,cwd:process.cwd()}),t.success(`Dlx completed`)}catch(e){t.error(`Dlx failed:`,e),process.exit(1)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const fmtCommand: CommandDef<ArgsDef>;
@@ -0,0 +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({cwd:i}),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)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const gitCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{exec as n}from"dugite";import{lintStagedFiles as r,lintCommitMessage as i,setupGit as a}from"../modules/git.mjs";export const gitCommand=e({meta:{name:`git`,description:`Git operations`},subCommands:{staged:e({meta:{name:`staged`,description:`Check staged files`},async run(){await r()||process.exit(1)}}),"lint-commit":e({meta:{name:`lint-commit`,description:`Validate commit message`},async run(){await i()||process.exit(1)}}),setup:e({meta:{name:`setup`,description:`Setup Git hooks and configuration`},async run(){await a()||process.exit(1)}})},async run({rawArgs:e}){if(e.length===0){t.info(`Available subcommands: staged, lint-commit, setup`),t.info(`Git passthrough mode: basis git <git-command>`);return}let r=[`staged`,`lint-commit`,`setup`],i=e[0];if(!r.includes(i))try{let t=await n(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){t.error(`Git operation failed:`,e),process.exit(1)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const initCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{initProject as n}from"../modules/init.mjs";export const initCommand=e({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 n(process.cwd(),{force:e.force,skipGitCheck:e[`skip-git-check`],skipInstall:e[`skip-install`]})}catch(e){t.error(`Init failed:`,e),process.exit(1)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const lintCommand: CommandDef<ArgsDef>;
@@ -0,0 +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({cwd:i}),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)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const publishCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{readPackageJSON as n}from"pkg-types";import{resolve as r,dirname as i}from"pathe";import{existsSync as a}from"node:fs";import{loadConfig as o}from"../config.mjs";import{publishToNpm as s,publishGitOperations as c}from"../modules/publish.mjs";export const publishCommand=e({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 l=process.cwd(),u;for(;l!==i(l);){let e=r(l,`basis.config.ts`);if(a(e)){u=e;break}l=i(l)}let{config:d}=await o({cwd:u?i(u):process.cwd()});if(await s({tag:e.tag,git:e.git,access:e.access||void 0,dryRun:e[`dry-run`],otp:e.otp},d.publish||{}),t.success(`Package published successfully`),e.git&&d.publish?.git){t.info(`Creating git tag and commit...`);let e=(await n(process.cwd())).version;e&&(await c(e,d.publish.git),t.success(`Git operations completed`))}}catch(e){t.error(`Publish failed:`,e),process.exit(1)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const removeCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{removeDependency as n}from"nypm";export const removeCommand=e({meta:{name:`remove`,description:`Remove dependencies`},async run({rawArgs:e}){e.length===0&&(t.error(`Please specify at least one package name`),t.info(`Example: basis remove lodash`),process.exit(1));let r=e.filter(e=>!e.startsWith(`-`));r.length===0&&(t.error(`Please specify at least one package name`),process.exit(1));try{await n(r,{cwd:process.cwd()}),t.success(`Removed ${r.join(`, `)}`)}catch(e){t.error(`Remove packages failed:`,e),process.exit(1)}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const runCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{runScript as n}from"nypm";import{createJiti as r}from"jiti";import{loadConfig as i}from"../config.mjs";export const runCommand=e({meta:{name:`run`,description:`Run scripts or files`},async run({rawArgs:e}){e.length===0&&(t.error(`Please specify a script name or file path`),process.exit(1));let[a,...o]=e,s=process.cwd(),{config:c}=await i({cwd:s}),l=c.run?.config;try{await n(a,{cwd:s,args:o});return}catch(e){try{await r(s,l).import(a);return}catch(n){t.error(`Run failed:`),t.error(` runScript error: ${String(e)}`),t.error(` jiti error: ${String(n)}`),t.info(`\nTried to run "${a}" as both a package.json script and a file, but both failed.`),process.exit(1)}}}});
@@ -0,0 +1,2 @@
1
+ import { type CommandDef, type ArgsDef } from "citty";
2
+ export declare const versionCommand: CommandDef<ArgsDef>;
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";import{consola as t}from"consola";import{readPackageJSON as n,writePackageJSON as r,resolvePackageJSON as i}from"pkg-types";import{loadConfig as a}from"../config.mjs";import{calculateNewVersion as o}from"../modules/version.mjs";export const versionCommand=e({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:s}=await a(),c={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)?c[t]=!0:c.version=t}let l=process.cwd(),u=await n(l),d=u.version;if(!d)throw Error(`No version found in package.json`);let f=o(d,c,s.version||{});if(!c.allowSameVersion&&f===d)throw Error(`Version unchanged: ${d}. Use --allow-same-version to allow this.`);await r(await i(l),{...u,version:f}),t.success(`Version updated: ${d} → ${f}`)}catch(e){t.error(`Version update failed:`,e),process.exit(1)}}});
package/dist/config.d.mts CHANGED
@@ -1 +1,24 @@
1
- export { e as defaultConfig, d as defineBasisConfig } from './shared/basis.DoHZYvYm.mjs';
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.mjs";
2
+ import * as c12 from "c12";
3
+ import { LoadConfigOptions } from "c12";
4
+ import { defineBuildConfig } from "@funish/build/config";
5
+
6
+ //#region src/config.d.ts
7
+ /**
8
+ * Define a Basis configuration
9
+ */
10
+ declare function defineBasisConfig(config: BasisConfig): BasisConfig;
11
+ /**
12
+ * Load Basis configuration
13
+ */
14
+ declare function loadConfig(options?: LoadConfigOptions<BasisConfig>): Promise<c12.ResolvedConfig<{
15
+ lint?: LintConfig;
16
+ fmt?: FmtConfig;
17
+ git?: GitConfig;
18
+ run?: RunConfig;
19
+ audit?: AuditConfig;
20
+ version?: VersionConfig;
21
+ publish?: PublishConfig;
22
+ }, c12.ConfigLayerMeta>>;
23
+ //#endregion
24
+ export { defineBasisConfig, defineBuildConfig, loadConfig };
package/dist/config.mjs CHANGED
@@ -1 +1 @@
1
- function t(e){return e}const i={lint:{dependencies:{checkSecurity:!0},structure:{requiredFiles:["package.json"]}},git:{hooks:{},config:{core:{autocrlf:"input"}},commitMsg:{types:["feat","fix","docs","style","refactor","perf","test","build","ci","chore","revert"]},autoSetup:!0,autoInitGit:!0,skipGitCheck:!1,force:!1},version:{tagPrefix:"v",prereleaseId:"edge"},publish:{defaultTag:"edge",stableTag:"latest"}};export{i as defaultConfig,t as defineBasisConfig};
1
+ import{n as e,r as t,t as n}from"./_chunks/config.mjs";export{n as defineBasisConfig,e as defineBuildConfig,t as loadConfig};
package/dist/index.d.mts CHANGED
@@ -1,178 +1,2 @@
1
- import { B as BasisConfig, I as InitOptions, V as VersionOptions, P as PublishOptions, a as VersionUpdateResult, b as PublishResult, C as CommitMessage, G as GitConfig, c as GitConfigData, L as LintConfig } from './shared/basis.DoHZYvYm.mjs';
2
- export { f as CommitMsgConfig, j as GitConfigSection, i as GitConfigValue, l as PublishConfig, g as VALID_GIT_HOOKS, h as ValidGitHook, k as VersionConfig, e as defaultConfig, d as defineBasisConfig } from './shared/basis.DoHZYvYm.mjs';
3
- import * as c12 from 'c12';
4
- import { LoadConfigOptions } from 'c12';
5
-
6
- /**
7
- * Basis core utilities for programmatic usage
8
- * Only includes methods that provide actual value beyond simple function calls
9
- */
10
- declare class Basis {
11
- private config;
12
- private cwd;
13
- constructor(cwd?: string);
14
- /**
15
- * Get current working directory
16
- */
17
- getCwd(): string;
18
- /**
19
- * Set working directory and reset cached config
20
- */
21
- setCwd(cwd: string): void;
22
- /**
23
- * Load configuration from file or cache
24
- */
25
- getConfig(): Promise<BasisConfig>;
26
- /**
27
- * Reload configuration from file
28
- */
29
- reloadConfig(): Promise<BasisConfig>;
30
- /**
31
- * Run complete project setup (init + git setup)
32
- */
33
- setup(options?: InitOptions): Promise<boolean>;
34
- /**
35
- * Run complete release workflow (lint + version + publish)
36
- */
37
- release(versionOptions?: VersionOptions, publishOptions?: PublishOptions): Promise<{
38
- version: VersionUpdateResult;
39
- publish: PublishResult;
40
- }>;
41
- }
42
- /**
43
- * Create a new Basis instance
44
- */
45
- declare function createBasis(cwd?: string): Basis;
46
-
47
- /**
48
- * Parse commit message into structured format
49
- */
50
- declare function parseCommitMessage(message: string): CommitMessage | null;
51
- /**
52
- * Validate commit message against rules
53
- */
54
- declare function validateCommitMessage(message: string, config?: GitConfig["commitMsg"]): {
55
- valid: boolean;
56
- errors: string[];
57
- };
58
- /**
59
- * Lint commit message from Git
60
- */
61
- declare function lintCommitMessage(cwd?: string, config?: GitConfig["commitMsg"]): Promise<boolean>;
62
- /**
63
- * Read Git configuration from .git/config using ini parser
64
- */
65
- declare function readGitConfig(cwd?: string): Promise<GitConfigData>;
66
- /**
67
- * Write Git configuration to .git/config using ini format
68
- */
69
- declare function writeGitConfig(config: GitConfigData, cwd?: string): Promise<void>;
70
- /**
71
- * Setup Git configuration with backup and safe merging
72
- */
73
- declare function setupGitConfig(cwd?: string, config?: GitConfig["config"]): Promise<boolean>;
74
- /**
75
- * Reset Git configuration with backup
76
- */
77
- declare function resetGitConfig(cwd?: string, keepUser?: boolean, options?: {
78
- updateConfig?: boolean;
79
- }): Promise<boolean>;
80
- /**
81
- * Setup Git hooks
82
- */
83
- declare function setupGitHooks(cwd?: string, config?: GitConfig["hooks"]): Promise<boolean>;
84
- /**
85
- * Initialize Git repository
86
- */
87
- declare function initGitRepo(cwd?: string): Promise<boolean>;
88
- /**
89
- * Run comprehensive Git setup
90
- */
91
- declare function setupGit(cwd?: string): Promise<boolean>;
92
- /**
93
- * Remove Git hooks
94
- */
95
- declare function removeGitHooks(cwd?: string, hooksToRemove?: string[], options?: {
96
- updateConfig?: boolean;
97
- }): Promise<boolean>;
98
-
99
- /**
100
- * Initialize basis configuration in the current project
101
- */
102
- declare function init(cwd?: string, options?: InitOptions): Promise<boolean>;
103
-
104
- /**
105
- * Get staged files (only existing files, not deleted ones)
106
- */
107
- declare function getStagedFiles(): string[];
108
- /**
109
- * Get all project files based on patterns using fast-glob
110
- */
111
- declare function getProjectFiles(cwd: string, patterns?: string[], exclude?: string[]): Promise<string[]>;
112
- /**
113
- * Lint staged files
114
- */
115
- declare function lintStaged(cwd?: string, config?: LintConfig["staged"]): Promise<boolean>;
116
- /**
117
- * Lint entire project using commands (similar to staged but for all project files)
118
- */
119
- declare function lintProject(cwd?: string, config?: LintConfig["project"]): Promise<boolean>;
120
- /**
121
- * Check dependencies
122
- */
123
- declare function lintDependencies(cwd?: string, config?: LintConfig["dependencies"], fix?: boolean): Promise<boolean>;
124
- /**
125
- * Check project structure
126
- */
127
- declare function lintStructure(cwd?: string, config?: LintConfig["structure"], fix?: boolean): Promise<boolean>;
128
- /**
129
- * Check documentation
130
- */
131
- declare function lintDocs(cwd?: string, config?: LintConfig["docs"], fix?: boolean): Promise<boolean>;
132
- /**
133
- * Run all lint checks
134
- */
135
- declare function lintAll(cwd?: string, fix?: boolean): Promise<boolean>;
136
-
137
- /**
138
- * Publish package to npm registry
139
- */
140
- declare function publishPackage(cwd: string, options?: PublishOptions): Promise<PublishResult>;
141
-
142
- /**
143
- * Update package.json version
144
- */
145
- declare function updatePackageVersion(cwd: string, options?: VersionOptions): Promise<VersionUpdateResult>;
146
-
147
- declare function loadConfig(options?: LoadConfigOptions<BasisConfig>): Promise<c12.ResolvedConfig<BasisConfig, c12.ConfigLayerMeta>>;
148
- /**
149
- * Check if file or directory exists
150
- */
151
- declare function fileExists(path: string): Promise<boolean>;
152
- /**
153
- * Get package manager specific commands
154
- */
155
- declare function getPackageManagerCommands(packageManager: string): {
156
- outdated: string;
157
- audit: string;
158
- execPrefix: string;
159
- remove: string;
160
- update: string;
161
- auditFix: string;
162
- } | {
163
- outdated: string;
164
- audit: null;
165
- execPrefix: string;
166
- remove: string;
167
- update: string;
168
- auditFix: null;
169
- } | {
170
- outdated: null;
171
- audit: null;
172
- execPrefix: string;
173
- remove: null;
174
- update: null;
175
- auditFix: null;
176
- };
177
-
178
- export { Basis, BasisConfig, CommitMessage, GitConfig, GitConfigData, InitOptions, LintConfig, PublishOptions, PublishResult, VersionOptions, VersionUpdateResult, createBasis, fileExists, getPackageManagerCommands, getProjectFiles, getStagedFiles, init, initGitRepo, lintAll, lintCommitMessage, lintDependencies, lintDocs, lintProject, lintStaged, lintStructure, loadConfig, parseCommitMessage, publishPackage, readGitConfig, removeGitHooks, resetGitConfig, setupGit, setupGitConfig, setupGitHooks, updatePackageVersion, validateCommitMessage, writeGitConfig };
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.mjs";
2
+ export { AuditConfig, BasisConfig, CommitMessage, CommitMsgConfig, FmtConfig, GitConfig, InitOptions, LintConfig, PublishConfig, PublishOptions, RunConfig, StagedConfig, VALID_GIT_HOOKS, ValidGitHook, VersionConfig, VersionOptions };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export{defaultConfig,defineBasisConfig}from"./config.mjs";import{s as e}from"./shared/basis.CyWSd-ys.mjs";export{i as initGitRepo,l as lintCommitMessage,p as parseCommitMessage,r as readGitConfig,d as removeGitHooks,b as resetGitConfig,a as setupGitConfig,c as setupGitHooks,v as validateCommitMessage,w as writeGitConfig}from"./shared/basis.CyWSd-ys.mjs";import{i as s}from"./shared/basis.5if__eE1.mjs";import{l as o}from"./shared/basis.Cc1QkX4i.mjs";export{a as getProjectFiles,g as getStagedFiles,d as lintDependencies,f as lintDocs,c as lintProject,b as lintStaged,e as lintStructure}from"./shared/basis.Cc1QkX4i.mjs";import{p as a}from"./shared/basis.CYJFGkEy.mjs";import{u as r}from"./shared/basis.4m3-erzm.mjs";import{l as p}from"./shared/basis.BrlVPuDi.mjs";export{f as fileExists,g as getPackageManagerCommands}from"./shared/basis.BrlVPuDi.mjs";import"node:child_process";import"node:fs/promises";import"c12/update";import"consola";import"defu";import"ini";import"pathe";import"magicast";import"nypm";import"pkg-types";import"fast-glob";import"micromatch";import"semver";import"c12";class c{config=null;cwd;constructor(t=process.cwd()){this.cwd=t}getCwd(){return this.cwd}setCwd(t){this.cwd=t,this.config=null}async getConfig(){if(!this.config){const{config:t}=await p({cwd:this.cwd});this.config=t}return this.config}async reloadConfig(){return this.config=null,await this.getConfig()}async setup(t={}){return await s(this.cwd,t)?await e(this.cwd):!1}async release(t={},n={}){if(!await o(this.cwd))throw new Error("Lint checks failed. Fix issues before releasing.");const m=await r(this.cwd,t),g=await a(this.cwd,n);return{version:m,publish:g}}}function f(i=process.cwd()){return new c(i)}const l=["applypatch-msg","pre-applypatch","post-applypatch","pre-commit","pre-merge-commit","prepare-commit-msg","commit-msg","post-commit","pre-rebase","post-checkout","post-merge","pre-push","pre-receive","update","proc-receive","post-receive","post-update","reference-transaction","push-to-checkout","pre-auto-gc","post-rewrite","sendemail-validate","fsmonitor-watchman","p4-changelist","p4-prepare-changelist","p4-post-changelist","p4-pre-submit","post-index-change"];export{c as Basis,l as VALID_GIT_HOOKS,f as createBasis,s as init,o as lintAll,p as loadConfig,a as publishPackage,e as setupGit,r as updatePackageVersion};
1
+ const e=`applypatch-msg.pre-applypatch.post-applypatch.pre-commit.pre-merge-commit.prepare-commit-msg.commit-msg.post-commit.pre-rebase.post-checkout.post-merge.pre-push.pre-receive.update.proc-receive.post-receive.post-update.reference-transaction.push-to-checkout.pre-auto-gc.post-rewrite.sendemail-validate.fsmonitor-watchman.p4-changelist.p4-prepare-changelist.p4-post-changelist.p4-pre-submit.post-index-change`.split(`.`);export{e as VALID_GIT_HOOKS};