@funish/basis 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -427
- package/dist/THIRD-PARTY-LICENSES.md +276 -0
- package/dist/_chunks/config.mjs +1 -0
- package/dist/_chunks/libs/common.d.mts +6970 -0
- package/dist/_chunks/libs/common.mjs +1 -0
- package/dist/_chunks/types.d.mts +194 -0
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +8 -1
- package/dist/commands/add.d.mts +2 -0
- package/dist/commands/add.mjs +1 -0
- package/dist/commands/audit.d.mts +2 -0
- package/dist/commands/audit.mjs +1 -0
- package/dist/commands/build.d.mts +2 -0
- package/dist/commands/build.mjs +1 -0
- package/dist/commands/check.d.mts +2 -0
- package/dist/commands/check.mjs +1 -0
- package/dist/commands/dlx.d.mts +2 -0
- package/dist/commands/dlx.mjs +1 -0
- package/dist/commands/fmt.d.mts +2 -0
- package/dist/commands/fmt.mjs +1 -0
- package/dist/commands/git.d.mts +2 -0
- package/dist/commands/git.mjs +1 -0
- package/dist/commands/init.d.mts +2 -0
- package/dist/commands/init.mjs +1 -0
- package/dist/commands/lint.d.mts +2 -0
- package/dist/commands/lint.mjs +1 -0
- package/dist/commands/publish.d.mts +2 -0
- package/dist/commands/publish.mjs +1 -0
- package/dist/commands/remove.d.mts +2 -0
- package/dist/commands/remove.mjs +1 -0
- package/dist/commands/run.d.mts +2 -0
- package/dist/commands/run.mjs +1 -0
- package/dist/commands/version.d.mts +2 -0
- package/dist/commands/version.mjs +1 -0
- package/dist/config.d.mts +24 -1
- package/dist/config.mjs +1 -1
- package/dist/index.d.mts +2 -178
- package/dist/index.mjs +1 -1
- package/package.json +65 -53
- package/LICENSE +0 -21
- package/dist/chunks/add.cjs +0 -1
- package/dist/chunks/add.mjs +0 -1
- package/dist/chunks/config.cjs +0 -1
- package/dist/chunks/config.mjs +0 -1
- package/dist/chunks/git.cjs +0 -1
- package/dist/chunks/git.mjs +0 -1
- package/dist/chunks/init.cjs +0 -1
- package/dist/chunks/init.mjs +0 -1
- package/dist/chunks/install.cjs +0 -1
- package/dist/chunks/install.mjs +0 -1
- package/dist/chunks/lint.cjs +0 -1
- package/dist/chunks/lint.mjs +0 -1
- package/dist/chunks/publish.cjs +0 -1
- package/dist/chunks/publish.mjs +0 -1
- package/dist/chunks/remove.cjs +0 -1
- package/dist/chunks/remove.mjs +0 -1
- package/dist/chunks/run.cjs +0 -1
- package/dist/chunks/run.mjs +0 -1
- package/dist/chunks/version.cjs +0 -1
- package/dist/chunks/version.mjs +0 -1
- package/dist/cli.cjs +0 -2
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/config.cjs +0 -1
- package/dist/config.d.cts +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -178
- package/dist/index.d.ts +0 -178
- package/dist/shared/basis.4m3-erzm.mjs +0 -1
- package/dist/shared/basis.5if__eE1.mjs +0 -8
- package/dist/shared/basis.Bqr6BGbD.cjs +0 -1
- package/dist/shared/basis.BrlVPuDi.mjs +0 -1
- package/dist/shared/basis.Bz4YLlJG.cjs +0 -1
- package/dist/shared/basis.CGkMo_WB.cjs +0 -3
- package/dist/shared/basis.CYJFGkEy.mjs +0 -1
- package/dist/shared/basis.Cc1QkX4i.mjs +0 -3
- package/dist/shared/basis.CyWSd-ys.mjs +0 -10
- package/dist/shared/basis.D3fInv-P.cjs +0 -1
- package/dist/shared/basis.DoHZYvYm.d.cts +0 -275
- package/dist/shared/basis.DoHZYvYm.d.mts +0 -275
- package/dist/shared/basis.DoHZYvYm.d.ts +0 -275
- package/dist/shared/basis.GHY7v-ns.cjs +0 -10
- package/dist/shared/basis.iEUClefn.cjs +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e}export{e as t};
|
|
@@ -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
|
|
2
|
+
import"./_chunks/libs/common.mjs";import{n 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{execSync as v,spawn as y}from"node:child_process";import b from"micromatch";import{resolve as x}from"pathe";import{createJiti as S}from"jiti";import C from"semver";import w from"fast-glob";async function T(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 ee=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 T(process.cwd(),{force:e.force,skipGitCheck:e[`skip-git-check`],skipInstall:e[`skip-install`]})}catch(e){r.error(`Init failed:`,e),process.exit(1)}}}),E=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)}}}),D=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)}}}),O=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)}}}),k=t({meta:{name:`build`,description:`Build project`},async run({rawArgs:e}){try{await h(`obuild`,{args:e,cwd:process.cwd()}),r.success(`Build completed`)}catch(e){r.error(`Build failed:`,e),process.exit(1)}}});async function A(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 j(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 A(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)&&b.isMatch(t.split(`/`).pop()||t,e));if(i.length!==0){r.info(`Running ${n} for ${i.length} file(s) matching ${e}`);try{let[e,...r]=n.split(` `);await new Promise((n,i)=>{y(e,r,{cwd:t,stdio:`inherit`,shell:!0}).on(`close`,e=>{e===0?n():i(Error(`Command exited with code ${e}`))})});let a=[];for(let e of i)try{await c(x(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 M=[`feat`,`fix`,`docs`,`style`,`refactor`,`perf`,`test`,`build`,`ci`,`chore`,`revert`];function N(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 P(t=process.cwd()){let{config:n}=await e({cwd:t}),i=n.git?.commitMsg,a=i?.types||M,o=i?.maxLength||72,c=i?.minLength||10,l=i?.scopeRequired||!1,d=i?.allowedScopes||[],f;try{let e=x(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=N(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 F(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=x(t,`.git/hooks`);try{for(let[e,t]of Object.entries(i))await l(x(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 I(e=process.cwd()){return r.start(`Setting up Git configuration`),await F(e)?(r.success(`Git setup completed`),!0):!1}const L=t({meta:{name:`git`,description:`Git operations`},subCommands:{staged:t({meta:{name:`staged`,description:`Check staged files`},async run(){await j()||process.exit(1)}}),"lint-commit":t({meta:{name:`lint-commit`,description:`Validate commit message`},async run(){await P()||process.exit(1)}}),setup:t({meta:{name:`setup`,description:`Setup Git hooks and configuration`},async run(){await I()||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)}}}),R=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 S(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 z(e,t,n){if(t.version){if(C.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(!C.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=C.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`)?C.inc(e,a,i):C.inc(e,a);if(!o)throw Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return o}const B=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=z(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 V(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 m(n))?.name||`npm`,c=t.npm||{tag:`latest`,access:`public`},l=e.tag;if(!l&&a&&a.includes(`-`)){let e=a.match(/-(\w+)\.\d+$/);e&&(l=e[1])}l=l||c.tag||`latest`;let u=(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);await new Promise((e,t)=>{y(s,[`publish`,...u],{stdio:`inherit`,shell:!0}).on(`close`,n=>{n===0?e():t(Error(`${s} publish exited with code ${n}`))})});let d=c.additionalTag;!e.dryRun&&d&&d!==l&&v(`npm dist-tag add ${o}@${a} ${d}`,{cwd:n,stdio:`inherit`})}async function H(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 U=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 V({tag:t.tag,git:t.git,access:t.access||void 0,dryRun:t[`dry-run`],otp:t.otp},n.publish||{}),r.success(`Package published successfully`),t.git&&n.publish?.git){r.info(`Creating git tag and commit...`);let e=(await i(process.cwd())).version;e&&(await H(e,n.publish.git),r.success(`Git operations completed`))}}catch(e){r.error(`Publish failed:`,e),process.exit(1)}}}),W={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 G(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=W[e];if(!n.outdated)r.info(`Skipping outdated check for ${e}`);else try{v(`${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=W[e];if(!n.audit)r.info(`Skipping security audit for ${e}`);else try{v(`${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 K(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 K(e){try{return await w([`node_modules/*/package.json`,`node_modules/@*/*/package.json`,`node_modules/@*/*/*/package.json`],{cwd:e,onlyFiles:!0,absolute:!0})}catch{return[]}}async function q(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(x(t,n))}catch{n.includes(`*`)||n.includes(`?`)?(await w(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 w(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 w(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 J(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([G(t,a.dependencies,n),q(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 Y=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 J(t,e.fix);else{let r=[];e.dependencies&&r.push(()=>G(t,void 0,e.fix)),e.structure&&r.push(()=>q(t));for(let e of r)await e()||(n=!1)}n||(r.error(`Some audits failed`),process.exit(1))}}),X=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)}}}),Z=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)}}}),Q=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:ee,lint:E,fmt:D,check:O,build:k,git:L,run:R,version:B,publish:U,audit:Y,add:X,remove:Z,dlx:Q}})).catch(e=>{r.error(e),process.exit(1)});export{};
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
1
|
+
import{defineCommand as e}from"citty";import{consola as t}from"consola";import{dlx as n}from"nypm";export const buildCommand=e({meta:{name:`build`,description:`Build project`},async run({rawArgs:e}){try{await n(`obuild`,{args:e,cwd:process.cwd()}),t.success(`Build completed`)}catch(e){t.error(`Build failed:`,e),process.exit(1)}}});
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
1
|
+
import{defineCommand as e}from"citty";import{consola as t}from"consola";import{readPackageJSON as n}from"pkg-types";import{loadConfig as r}from"../config.mjs";import{publishToNpm as i,publishGitOperations as a}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{config:o}=await r();if(await i({tag:e.tag,git:e.git,access:e.access||void 0,dryRun:e[`dry-run`],otp:e.otp},o.publish||{}),t.success(`Package published successfully`),e.git&&o.publish?.git){t.info(`Creating git tag and commit...`);let e=(await n(process.cwd())).version;e&&(await a(e,o.publish.git),t.success(`Git operations completed`))}}catch(e){t.error(`Publish failed:`,e),process.exit(1)}}});
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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
|
-
|
|
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 { t as defineBuildConfig } from "./_chunks/libs/common.mjs";
|
|
3
|
+
import * as c12 from "c12";
|
|
4
|
+
import { LoadConfigOptions } from "c12";
|
|
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
|
-
|
|
1
|
+
import{t as e}from"./_chunks/libs/common.mjs";import{n 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 {
|
|
2
|
-
export {
|
|
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
|
-
|
|
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};
|