@funish/basis 0.1.2 → 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.1-2-e6uu.cjs +0 -8
- package/dist/shared/basis.4m3-erzm.mjs +0 -1
- package/dist/shared/basis.BDhrNAQD.mjs +0 -10
- 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.C4FYR2wo.mjs +0 -8
- 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.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.DuZo2uz1.cjs +0 -10
package/dist/index.d.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
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.js';
|
|
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.js';
|
|
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,8 +0,0 @@
|
|
|
1
|
-
"use strict";const update=require("c12/update"),consola=require("consola"),magicast=require("magicast"),nypm=require("nypm"),pathe=require("pathe"),pkgTypes=require("pkg-types"),utils=require("./basis.D3fInv-P.cjs"),git=require("./basis.DuZo2uz1.cjs"),S={ts:{ext:"ts",label:"TypeScript"},mjs:{ext:"mjs",label:"ES Module"},cjs:{ext:"cjs",label:"CommonJS"}};function J(i,r="npm"){const o=magicast.parseModule(i==="cjs"?`const { defineBasisConfig } = require("@funish/basis");
|
|
2
|
-
|
|
3
|
-
module.exports = defineBasisConfig({});`:`import { defineBasisConfig } from "@funish/basis";
|
|
4
|
-
|
|
5
|
-
export default defineBasisConfig({});`),{execPrefix:n}=utils.getPackageManagerCommands(r),c={git:{hooks:{"pre-commit":`${n} basis lint --staged`,"commit-msg":`${n} basis git --lint-commit`}}},a=o.exports.default.$args[0];return Object.assign(a,c),a.$ast.leadingComments=[{type:"Block",value:`
|
|
6
|
-
Configure your project here
|
|
7
|
-
See: https://github.com/funish/basis/tree/main/packages/basis#configuration
|
|
8
|
-
`}],magicast.generateCode(o).code}async function A(i){if(await utils.fileExists(pathe.resolve(i,"tsconfig.json")))return"ts";try{if((await pkgTypes.readPackageJSON(i)).type==="module")return"mjs"}catch{}return"ts"}async function init(i=process.cwd(),r={}){const{force:o=!1,skipGitCheck:n=!1,skipInstall:c=!1}=r;consola.consola.start("Initializing basis configuration...");const a=await A(i),d=await consola.consola.prompt("Choose config file format:",{type:"select",initial:a,options:Object.entries(S).map(([e,{label:s,ext:p}])=>({value:e,label:`${s} (${p}) ${a===e?"(recommended)":""}`}))}),g=S[d].ext,m=`basis.config.${g}`,k=pathe.resolve(i,m);if(await utils.fileExists(k)&&!o)return consola.consola.error(`${m} already exists. Use --force to overwrite.`),!1;let t=!1;if(!n)if(await utils.fileExists(pathe.resolve(i,".git")))t=await consola.consola.prompt("Setup Git hooks and configuration?",{type:"confirm",initial:!0});else if(consola.consola.info("No Git repository found."),await consola.consola.prompt("Initialize Git repository?",{type:"confirm",initial:!0}))try{await git.initGitRepo(i)?t=await consola.consola.prompt("Setup Git hooks and configuration?",{type:"confirm",initial:!0}):(consola.consola.warn("Git initialization failed, skipping Git setup"),t=!1)}catch(e){consola.consola.error("Failed to initialize Git repository:",e),consola.consola.warn("Skipping Git setup"),t=!1}else consola.consola.info("Skipping Git initialization"),t=!1;const w=(await nypm.detectPackageManager(i))?.name||"npm";await update.updateConfig({cwd:i,configFile:"basis.config",createExtension:`.${g}`,onCreate:()=>J(d,w)});let l=!1;c||(l=await consola.consola.prompt("Install @funish/basis dependency now?",{type:"confirm",initial:!0}));const h=await pkgTypes.findWorkspaceDir(i)===i;if(l)try{await nypm.addDevDependency(["@funish/basis"],{workspace:h})}catch(e){consola.consola.error("Failed to install @funish/basis:",e),consola.consola.info("You can install it manually with: basis add -D @funish/basis")}if(t)try{const e=pathe.resolve(i,"package.json");if(await utils.fileExists(e)){const s=await pkgTypes.readPackageJSON(e),p=w,u="basis git setup";s.scripts=s.scripts||{};const y=p==="yarn"?"prepare":"postinstall",f=s.scripts[y];let b=!1;f?.includes(u)||(s.scripts[y]=f?`${f} && ${u}`:u,b=!0),b&&await pkgTypes.writePackageJSON(e,s)}else consola.consola.warn("No package.json found. You'll need to run git setup manually.")}catch(e){consola.consola.error("Failed to update package.json:",e),consola.consola.warn("You can manually add 'basis git setup' to your postinstall script")}return t&&!l&&(await git.setupGit(i)||consola.consola.warn("Git setup failed, but basis config was created successfully")),consola.consola.success("Basis initialization completed!"),!0}exports.init=init;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{execSync as t}from"node:child_process";import{consola as l}from"consola";import{readPackageJSON as d,resolvePackageJSON as w,writePackageJSON as v}from"pkg-types";import s from"semver";import{l as u}from"./basis.BrlVPuDi.mjs";function h(e,o,m){if(o.version){if(s.valid(o.version))return o.version;throw new Error(`Invalid version format: ${o.version}. Please use semantic versioning format (e.g., 1.0.0, 2.1.0-alpha.1)`)}if(!s.valid(e))throw new Error(`Invalid current version format: ${e}. Please fix version in package.json to use semantic versioning format (e.g., 1.0.0)`);const r=s.prerelease(e),c=o.preid||(r&&typeof r[0]=="string"?r[0]:null)||m.prereleaseId||"edge";let a;o.major?a="major":o.minor?a="minor":o.prerelease?a=r?"prerelease":"prepatch":a=r?"prerelease":"patch";const i=a==="prerelease"||a.startsWith("pre")?s.inc(e,a,c):s.inc(e,a);if(!i)throw new Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return i}async function P(e,o={}){const{config:m}=await u({cwd:e}),r=m.version||{},c=await d(e),a=c.version;if(!a)throw new Error("No version found in package.json");const i=h(a,o,r),f=await w(e);await v(f,{...c,version:i});const p={oldVersion:a,newVersion:i};if(r.autoCommit){const n=o.message||r.commitMessage?.replace("{version}",i)||`chore: release v${i}`;try{t("git add package.json",{cwd:e}),t(`git commit -m "${n}"`,{cwd:e})}catch(g){l.warn("Failed to commit changes:",g)}}if(r.autoTag){const n=`${r.tagPrefix||"v"}${i}`;try{t(`git tag ${n}`,{cwd:e}),p.tagName=n}catch(g){l.warn("Failed to create git tag:",g)}}if(r.autoPush)try{t("git push",{cwd:e}),r.autoTag&&t("git push --tags",{cwd:e})}catch(n){l.warn("Failed to push changes:",n)}return p}export{P as u};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{execSync as p}from"node:child_process";import{readFile as h,unlink as M,writeFile as y,copyFile as O}from"node:fs/promises";import{updateConfig as S}from"c12/update";import{consola as a}from"consola";import{defu as x}from"defu";import v from"ini";import{resolve as u}from"pathe";import{l as d,f as g}from"./basis.BrlVPuDi.mjs";function G(){try{return p("git --version",{stdio:"pipe"}),!0}catch{return!1}}async function k(e,o=!1,r=!1){try{return await S({cwd:e,configFile:"basis.config",onUpdate:t=>{t.git&&(o&&t.git.hooks&&delete t.git.hooks,r&&t.git.config&&delete t.git.config,Object.keys(t.git).length===0&&delete t.git)}}),!0}catch{return!1}}const E=["feat","fix","docs","style","refactor","perf","test","build","ci","chore","revert"];function b(e){const o=e.trim().split(`
|
|
2
|
-
`),r=o[0].match(/^(\w+)(\(([^)]+)\))?(!)?:\s*(.+)$/);if(!r)return null;const[,t,,i,n,s]=r,c=o.slice(1).find(l=>l.trim())?.trim(),f=o.slice(-1)[0]?.trim();return{type:t,scope:i,description:s,body:c,footer:f,isBreaking:!!n||e.includes("BREAKING CHANGE:")}}function $(e,o={}){const r=[],{types:t=E,maxLength:i=72,minLength:n=10,scopeRequired:s=!1,allowedScopes:c=[]}=o,f=b(e);if(!f)return{valid:!1,errors:["Invalid commit format. Expected: type(scope): description"]};t.includes(f.type)||r.push(`Invalid type '${f.type}'. Allowed: ${t.join(", ")}`);const l=e.split(`
|
|
3
|
-
`)[0];return l.length>i&&r.push(`Header too long (${l.length}). Max: ${i}`),l.length<n&&r.push(`Header too short (${l.length}). Min: ${n}`),s&&!f.scope&&r.push("Scope is required"),f.scope&&c.length>0&&!c.includes(f.scope)&&r.push(`Invalid scope '${f.scope}'. Allowed: ${c.join(", ")}`),{valid:r.length===0,errors:r}}async function H(e=process.cwd(),o){if(!G())return a.warn("Git command not available, skipping commit message linting"),!0;const{config:r}=await d({cwd:e,overrides:o?{git:{commitMsg:o}}:void 0}),t=r.git?.commitMsg||{};let i;try{const s=u(".git/COMMIT_EDITMSG");await g(s)?i=(await h(s)).toString("utf8"):i=p("git log -1 --pretty=%B",{encoding:"utf8"}).trim()}catch(s){return a.error("Failed to read commit message:",s),!1}const n=$(i,t);return n.valid?!0:(a.error("Invalid commit message:"),n.errors.forEach(s=>a.error(` ${s}`)),!1)}async function j(e){const o=u(e,".git/config");if(!await g(o))return null;const r=new Date().toISOString().replace(/[:.]/g,"-"),t=u(e,`.git/config.backup.${r}`);try{return await O(o,t),t}catch(i){return a.warn("Failed to create Git config backup:",i),null}}async function m(e=process.cwd()){const o=u(e,".git/config");if(!await g(o))return{};try{const r=await h(o,"utf8");return v.parse(r)}catch(r){return a.warn("Failed to read .git/config:",r),{}}}async function w(e,o=process.cwd()){const r=u(o,".git/config");try{let t=v.stringify(e,{whitespace:!0});t=t.split(`
|
|
4
|
-
`).map(i=>i&&!i.startsWith("[")&&i.includes("=")?` ${i}`:i).join(`
|
|
5
|
-
`),await y(r,t,"utf8")}catch(t){throw a.error("Failed to write .git/config:",t),t}}function A(e,o){if(!o)return!0;for(const[r,t]of Object.entries(o)){if(typeof t!="object"||!t)continue;const i=e[r];if(!i||typeof i!="object")return!1;for(const[n,s]of Object.entries(t))if(s!==void 0&&i[n]!==s)return!1}return!0}async function C(e=process.cwd(),o){const{config:r}=await d({cwd:e,overrides:o?{git:{config:o}}:void 0}),t=r.git?.config||{};if(Object.keys(t).length===0)return!0;try{const i=await m(e);if(A(i,t))return!0;await j(e);const n=x(i,t);return await w(n,e),!0}catch(i){return a.error("Failed to setup Git configuration:",i),!1}}async function z(e=process.cwd(),o=!0,r={}){try{await j(e);const t=await m(e);if(!t||Object.keys(t).length===0)return!0;const i={};if(o&&t.user&&(i.user=t.user),t.core){const n=["repositoryformatversion","filemode","bare","logallrefupdates"],s={};n.forEach(c=>{t.core[c]!==void 0&&(s[c]=t.core[c])}),Object.keys(s).length>0&&(i.core=s)}return await w(i,e),r.updateConfig?await k(e,!1,!0):!0}catch(t){return a.error("Failed to reset Git configuration:",t),!1}}async function F(e=process.cwd(),o){const{config:r}=await d({cwd:e,overrides:o?{git:{hooks:o}}:void 0}),t=r.git?.hooks||{},i=u(e,".git/hooks");if(!await g(i))return a.error("Git hooks directory not found. Is this a Git repository?"),!1;let n=!0;for(const[s,c]of Object.entries(t)){const f=u(i,s);try{let l=`#!/bin/sh
|
|
6
|
-
|
|
7
|
-
`;if(typeof c=="string")l+=`${c}
|
|
8
|
-
`;else if(c&&typeof c=="object"&&"commands"in c){const I=c.commands;l+=`${I.join(`
|
|
9
|
-
`)}
|
|
10
|
-
`}await y(f,l,{mode:493})}catch(l){a.error(`Failed to setup ${s} hook:`,l),n=!1}}return n}async function B(e=process.cwd()){if(!G())return a.warn("Git command not available, cannot initialize repository"),!1;try{try{return p("git rev-parse --git-dir",{cwd:e,stdio:"pipe"}),!0}catch{return p("git init",{cwd:e,stdio:"inherit"}),a.success("Initialized Git repository"),!0}}catch(o){return a.error("Failed to initialize Git repository:",o),!1}}async function R(e=process.cwd()){const{config:o}=await d({cwd:e}),r=o.git||{},t=(await Promise.allSettled([C(e,r.config),F(e,r.hooks)])).filter(i=>i.status==="rejected"||i.status==="fulfilled"&&!i.value);return t.length===0?(a.success("Git setup completed successfully!"),!0):(a.error(`${t.length} Git setup step(s) failed`),!1)}async function q(e=process.cwd(),o,r={}){const t=u(e,".git/hooks");if(!await g(t))return a.warn("Git hooks directory not found. Is this a Git repository?"),!0;let i=!0,n;if(o&&o.length>0)n=o;else{const{config:s}=await d({cwd:e});n=Object.keys(s.git?.hooks||{})}for(const s of n){const c=u(t,s);if(await g(c))try{await M(c)}catch(f){a.error(`Failed to remove ${s} hook:`,f),i=!1}}if(!o&&r.updateConfig){const s=await k(e,!0,!1);i=i&&s}return i}export{C as a,z as b,F as c,q as d,B as i,H as l,b as p,m as r,R as s,$ as v,w};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const node_child_process=require("node:child_process"),consola=require("consola"),pkgTypes=require("pkg-types"),n=require("semver"),utils=require("./basis.D3fInv-P.cjs");function _interopDefaultCompat(e){return e&&typeof e=="object"&&"default"in e?e.default:e}const n__default=_interopDefaultCompat(n);function P(e,a,c){if(a.version){if(n__default.valid(a.version))return a.version;throw new Error(`Invalid version format: ${a.version}. Please use semantic versioning format (e.g., 1.0.0, 2.1.0-alpha.1)`)}if(!n__default.valid(e))throw new Error(`Invalid current version format: ${e}. Please fix version in package.json to use semantic versioning format (e.g., 1.0.0)`);const r=n__default.prerelease(e),t=a.preid||(r&&typeof r[0]=="string"?r[0]:null)||c.prereleaseId||"edge";let o;a.major?o="major":a.minor?o="minor":a.prerelease?o=r?"prerelease":"prepatch":o=r?"prerelease":"patch";const i=o==="prerelease"||o.startsWith("pre")?n__default.inc(e,o,t):n__default.inc(e,o);if(!i)throw new Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return i}async function updatePackageVersion(e,a={}){const{config:c}=await utils.loadConfig({cwd:e}),r=c.version||{},t=await pkgTypes.readPackageJSON(e),o=t.version;if(!o)throw new Error("No version found in package.json");const i=P(o,a,r),u=await pkgTypes.resolvePackageJSON(e);await pkgTypes.writePackageJSON(u,{...t,version:i});const g={oldVersion:o,newVersion:i};if(r.autoCommit){const s=a.message||r.commitMessage?.replace("{version}",i)||`chore: release v${i}`;try{node_child_process.execSync("git add package.json",{cwd:e}),node_child_process.execSync(`git commit -m "${s}"`,{cwd:e})}catch(l){consola.consola.warn("Failed to commit changes:",l)}}if(r.autoTag){const s=`${r.tagPrefix||"v"}${i}`;try{node_child_process.execSync(`git tag ${s}`,{cwd:e}),g.tagName=s}catch(l){consola.consola.warn("Failed to create git tag:",l)}}if(r.autoPush)try{node_child_process.execSync("git push",{cwd:e}),r.autoTag&&node_child_process.execSync("git push --tags",{cwd:e})}catch(s){consola.consola.warn("Failed to push changes:",s)}return g}exports.updatePackageVersion=updatePackageVersion;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{access as a}from"node:fs/promises";import{loadConfig as t}from"c12";import{defaultConfig as u}from"../config.mjs";async function n(e={}){return await t({name:"basis",cwd:process.cwd(),...e,defaults:{...u,...e.defaults}})}async function d(e){try{return await a(e),!0}catch{return!1}}function r(e){switch(e){case"yarn":return{outdated:"yarn outdated --json",audit:"yarn audit --level moderate",execPrefix:"yarn exec",remove:"yarn remove",update:"yarn upgrade",auditFix:"yarn upgrade"};case"pnpm":return{outdated:"pnpm outdated --format table",audit:"pnpm audit --audit-level moderate",execPrefix:"pnpm exec",remove:"pnpm remove",update:"pnpm update",auditFix:"pnpm audit --fix"};case"bun":return{outdated:"bun outdated",audit:null,execPrefix:"bunx",remove:"bun remove",update:"bun update",auditFix:null};case"deno":return{outdated:null,audit:null,execPrefix:"deno task",remove:null,update:null,auditFix:null};default:return{outdated:"npm outdated --json",audit:"npm audit --audit-level moderate",execPrefix:"npx",remove:"npm uninstall",update:"npm update",auditFix:"npm audit fix"}}}export{d as f,r as g,n as l};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const node_child_process=require("node:child_process"),consola=require("consola"),nypm=require("nypm"),pkgTypes=require("pkg-types"),n=require("semver"),utils=require("./basis.D3fInv-P.cjs");function _interopDefaultCompat(a){return a&&typeof a=="object"&&"default"in a?a.default:a}const n__default=_interopDefaultCompat(n);function C(a,e,s){if(e.tag)return e.tag;if(e.stable||e.latest)return s.stableTag||"latest";if(n__default.prerelease(a)){const t=n__default.prerelease(a);return t&&t[0]||s.defaultTag||"edge"}return s.stableTag||"latest"}async function T(a,e,s){if(e.checkGitClean&&!s.skipTests)try{if(node_child_process.execSync("git status --porcelain",{cwd:a,encoding:"utf8"}).trim())throw new Error("Working directory is not clean. Commit your changes first.")}catch(t){consola.consola.warn("Could not check git status:",t)}if(e.checkTests&&!s.skipTests){consola.consola.start("Running tests...");try{e.testCommand?node_child_process.execSync(e.testCommand,{cwd:a,stdio:"inherit"}):await nypm.runScript("test",{cwd:a,silent:!1})}catch(t){throw consola.consola.error("Tests failed"),t}}if(e.buildCommand&&!s.skipBuild){consola.consola.start("Building package...");try{e.buildCommand.includes(" ")?node_child_process.execSync(e.buildCommand,{cwd:a,stdio:"inherit"}):await nypm.runScript(e.buildCommand,{cwd:a,silent:!1})}catch(t){throw consola.consola.error("Build failed"),t}}}async function $(a,e){if(e.autoGitPush)try{node_child_process.execSync("git push",{cwd:a}),e.createGitTag&&node_child_process.execSync("git push --tags",{cwd:a})}catch(s){consola.consola.warn("Failed to push changes:",s)}}async function publishPackage(a,e={}){const{config:s}=await utils.loadConfig({cwd:a}),t=s.publish||{},p=await pkgTypes.readPackageJSON(a),{name:o,version:r}=p;if(!o||!r)throw new Error("Missing name or version in package.json. Please ensure your package.json contains valid 'name' and 'version' fields.");if(!n__default.valid(r))throw new Error(`Invalid version format in package.json: ${r}. Please use semantic versioning format (e.g., 1.0.0, 2.1.0-alpha.1)`);const g=await nypm.detectPackageManager(a),d=g?.command||"npm";await T(a,t,e);const l=C(r,e,t),u=["publish","--tag",l,"--access",e.access||t.access||"public"];(e.registry||t.registry)&&u.push("--registry",e.registry||t.registry||""),e.dryRun&&u.push("--dry-run");const h=`${d} ${u.join(" ")}`;consola.consola.start("Publishing package...");try{if(node_child_process.execSync(h,{cwd:a,stdio:"inherit"}),!e.dryRun){const i=t.defaultTag||"edge";if(l!==i){consola.consola.start(`Also publishing to ${i} tag...`);try{let c;g?.name==="yarn"?c=`${d} tag add ${o}@${r} ${i}`:c=`${d} dist-tag add ${o}@${r} ${i}`,node_child_process.execSync(c,{cwd:a,stdio:"inherit"})}catch(c){consola.consola.warn(`Failed to add ${i} tag:`,c)}}await $(a,t)}return{packageName:o,version:r,publishTag:l,dryRun:e.dryRun||!1}}catch(i){throw consola.consola.error("Failed to publish package:",i),i}}exports.publishPackage=publishPackage;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{updateConfig as S}from"c12/update";import{consola as i}from"consola";import{parseModule as z,generateCode as B}from"magicast";import{detectPackageManager as v,addDevDependency as F}from"nypm";import{resolve as c}from"pathe";import{findWorkspaceDir as P,readPackageJSON as C,writePackageJSON as D}from"pkg-types";import{f as p,g as I}from"./basis.BrlVPuDi.mjs";import{i as J,s as M}from"./basis.BDhrNAQD.mjs";const j={ts:{ext:"ts",label:"TypeScript"},mjs:{ext:"mjs",label:"ES Module"},cjs:{ext:"cjs",label:"CommonJS"}};function N(t,l="npm"){const n=z(t==="cjs"?`const { defineBasisConfig } = require("@funish/basis");
|
|
2
|
-
|
|
3
|
-
module.exports = defineBasisConfig({});`:`import { defineBasisConfig } from "@funish/basis";
|
|
4
|
-
|
|
5
|
-
export default defineBasisConfig({});`),{execPrefix:r}=I(l),f={git:{hooks:{"pre-commit":`${r} basis lint --staged`,"commit-msg":`${r} basis git --lint-commit`}}},o=n.exports.default.$args[0];return Object.assign(o,f),o.$ast.leadingComments=[{type:"Block",value:`
|
|
6
|
-
Configure your project here
|
|
7
|
-
See: https://github.com/funish/basis/tree/main/packages/basis#configuration
|
|
8
|
-
`}],B(n).code}async function O(t){if(await p(c(t,"tsconfig.json")))return"ts";try{if((await C(t)).type==="module")return"mjs"}catch{}return"ts"}async function E(t=process.cwd(),l={}){const{force:n=!1,skipGitCheck:r=!1,skipInstall:f=!1}=l;i.start("Initializing basis configuration...");const o=await O(t),w=await i.prompt("Choose config file format:",{type:"select",initial:o,options:Object.entries(j).map(([a,{label:s,ext:m}])=>({value:a,label:`${s} (${m}) ${o===a?"(recommended)":""}`}))}),y=j[w].ext,b=`basis.config.${y}`,G=c(t,b);if(await p(G)&&!n)return i.error(`${b} already exists. Use --force to overwrite.`),!1;let e=!1;if(!r)if(await p(c(t,".git")))e=await i.prompt("Setup Git hooks and configuration?",{type:"confirm",initial:!0});else if(i.info("No Git repository found."),await i.prompt("Initialize Git repository?",{type:"confirm",initial:!0}))try{await J(t)?e=await i.prompt("Setup Git hooks and configuration?",{type:"confirm",initial:!0}):(i.warn("Git initialization failed, skipping Git setup"),e=!1)}catch(a){i.error("Failed to initialize Git repository:",a),i.warn("Skipping Git setup"),e=!1}else i.info("Skipping Git initialization"),e=!1;const h=(await v(t))?.name||"npm";await S({cwd:t,configFile:"basis.config",createExtension:`.${y}`,onCreate:()=>N(w,h)});let u=!1;f||(u=await i.prompt("Install @funish/basis dependency now?",{type:"confirm",initial:!0}));const $=await P(t)===t;if(u)try{await F(["@funish/basis"],{workspace:$})}catch(a){i.error("Failed to install @funish/basis:",a),i.info("You can install it manually with: basis add -D @funish/basis")}if(e)try{const a=c(t,"package.json");if(await p(a)){const s=await C(a),m=h,d="basis git setup";s.scripts=s.scripts||{};const k=m==="yarn"?"prepare":"postinstall",g=s.scripts[k];let x=!1;g?.includes(d)||(s.scripts[k]=g?`${g} && ${d}`:d,x=!0),x&&await D(a,s)}else i.warn("No package.json found. You'll need to run git setup manually.")}catch(a){i.error("Failed to update package.json:",a),i.warn("You can manually add 'basis git setup' to your postinstall script")}return e&&!u&&(await M(t)||i.warn("Git setup failed, but basis config was created successfully")),i.success("Basis initialization completed!"),!0}export{E as i};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const node_child_process=require("node:child_process"),promises=require("node:fs/promises"),consola=require("consola"),P=require("fast-glob"),$=require("micromatch"),nypm=require("nypm"),pathe=require("pathe"),pkgTypes=require("pkg-types"),utils=require("./basis.D3fInv-P.cjs");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const P__default=_interopDefaultCompat(P),$__default=_interopDefaultCompat($);function getStagedFiles(){try{const t=node_child_process.execSync("git diff --cached --name-only",{encoding:"utf8"}).trim().split(`
|
|
2
|
-
`).filter(Boolean),i=node_child_process.execSync("git diff --cached --name-only --diff-filter=D",{encoding:"utf8"}),o=new Set(i.trim().split(`
|
|
3
|
-
`).filter(Boolean));return t.filter(s=>!o.has(s))}catch{return[]}}async function getProjectFiles(t,i=["**/*"],o=["node_modules/**","dist/**","build/**",".git/**"]){try{return await P__default(i,{cwd:t,ignore:o,onlyFiles:!0,dot:!1,absolute:!1})}catch(s){return consola.consola.warn("Failed to scan project files:",s),[]}}async function lintStaged(t=process.cwd(),i){const{config:o}=await utils.loadConfig({cwd:t,overrides:i?{lint:{staged:i}}:void 0}),s=o.lint?.staged||{},e=getStagedFiles();if(e.length===0)return!0;if(Object.keys(s).length===0)return consola.consola.warn("No staged lint configuration found. Add lint.staged section to your basis.config.ts"),!0;let r=!1;const n=new Set;for(const[a,u]of Object.entries(s)){const f=e.filter(c=>!n.has(c)&&$__default.isMatch(c.split("/").pop()||c,a));if(f.length!==0){consola.consola.start(`Running staged lint for pattern: ${a}`);try{node_child_process.execSync(u,{stdio:"inherit",cwd:t});const c=[];for(const l of f)await utils.fileExists(pathe.resolve(t,l))&&c.push(l);c.length>0&&node_child_process.execSync(`git add ${c.join(" ")}`,{stdio:"inherit",cwd:t}),f.forEach(l=>n.add(l))}catch(c){r=!0,consola.consola.error(`Lint pattern '${a}' failed. Please fix the issues and try again:`,c)}}}return!r}async function lintProject(t=process.cwd(),i){const{config:o}=await utils.loadConfig({cwd:t,overrides:i?{lint:{project:i}}:void 0}),s=o.lint?.project||{};if(Object.keys(s).length===0)return consola.consola.warn("No project lint configuration found. Add lint.project section to your basis.config.ts"),!0;consola.consola.start("Running project-wide linting...");let e=!1;for(const[r,n]of Object.entries(s)){consola.consola.start(`Running project lint: ${r}`);try{node_child_process.execSync(n,{stdio:"inherit",cwd:t})}catch(a){e=!0,consola.consola.error(`Project lint pattern '${r}' failed. Please fix the issues and try again:`,a)}}return!e}async function lintDependencies(t=process.cwd(),i,o=!1){const{config:s}=await utils.loadConfig({cwd:t,overrides:i?{lint:{dependencies:i}}:void 0}),e=s.lint?.dependencies||{},r=s.lint?.fix?.dependencies||{};let n=!1;try{const a=await pkgTypes.readPackageJSON(t),u={...a.dependencies,...a.devDependencies},f=(await nypm.detectPackageManager(t))?.name||"npm",c=utils.getPackageManagerCommands(f);if(consola.consola.start("Checking dependencies..."),e.blockedPackages&&e.blockedPackages.length>0){const l=Object.keys(u).filter(d=>e.blockedPackages?.includes(d));if(l.length>0)if(o&&r.removeBlocked&&c.remove){consola.consola.start(`Removing blocked packages: ${l.join(", ")}`);try{for(const d of l)node_child_process.execSync(`${c.remove} ${d}`,{cwd:t,stdio:"inherit"});consola.consola.success(`Removed ${l.length} blocked packages`)}catch(d){consola.consola.error("Failed to remove blocked packages:",d),n=!0}}else consola.consola.error(`Blocked packages found: ${l.join(", ")}. Please remove these packages from your dependencies.`),n=!0}if(e.checkOutdated)if(c.outdated)try{node_child_process.execSync(c.outdated,{cwd:t,stdio:"pipe"})}catch(l){if(o&&r.updateOutdated&&c.update){consola.consola.start("Updating outdated dependencies...");try{node_child_process.execSync(c.update,{cwd:t,stdio:"inherit"}),consola.consola.success("Dependencies updated")}catch(d){consola.consola.error("Failed to update dependencies:",d),n=!0}}else consola.consola.warn("Some dependencies are outdated:",l)}else consola.consola.warn(`Outdated check not available for ${f}`);if(e.checkSecurity)if(c.audit)try{node_child_process.execSync(c.audit,{cwd:t,stdio:"pipe"})}catch(l){if(o&&r.fixSecurity&&c.auditFix){consola.consola.start("Fixing security vulnerabilities...");try{node_child_process.execSync(c.auditFix,{cwd:t,stdio:"inherit"}),consola.consola.success("Security fixes applied")}catch(d){consola.consola.error("Failed to fix security issues:",d),n=!0}}else consola.consola.error("Security vulnerabilities detected:",l),n=!0}else consola.consola.warn(`Security audit not available for ${f}`);if(e.allowedLicenses&&e.allowedLicenses.length>0){const{hasIssues:l,invalidLicenses:d}=await S(t,e.allowedLicenses);l&&(consola.consola.error("Packages with invalid licenses found:"),d.forEach(p=>consola.consola.error(` ${p}`)),n=!0)}}catch(a){consola.consola.error("Failed to check dependencies:",a),n=!0}return!n}async function v(t,i,o=!1){if(i.length===0)return!0;const s=(await Promise.all(i.map(async e=>({file:e,exists:await utils.fileExists(pathe.resolve(t,e))})))).filter(e=>!e.exists);if(s.length>0)if(o){consola.consola.start(`Creating missing files: ${s.map(e=>e.file).join(", ")}`);try{for(const{file:e}of s)await promises.writeFile(pathe.resolve(t,e),"","utf8");consola.consola.success(`Created ${s.length} missing files`)}catch(e){return consola.consola.error("Failed to create missing files:",e),!1}}else return s.forEach(({file:e})=>{consola.consola.error(`Required file missing: ${e}`)}),!1;return!0}async function R(t,i,o=!1){if(i.length===0)return!0;const s=(await Promise.all(i.map(async e=>({dir:e,exists:await utils.fileExists(pathe.resolve(t,e))})))).filter(e=>!e.exists);if(s.length>0)if(o){consola.consola.start(`Creating missing directories: ${s.map(e=>e.dir).join(", ")}`);try{for(const{dir:e}of s)await promises.mkdir(pathe.resolve(t,e),{recursive:!0});consola.consola.success(`Created ${s.length} missing directories`)}catch(e){return consola.consola.error("Failed to create missing directories:",e),!1}}else return s.forEach(({dir:e})=>{consola.consola.error(`Required directory missing: ${e}`)}),!1;return!0}async function D(t,i,o){const s=new RegExp(o),e=(await getProjectFiles(t,[i])).filter(r=>{const n=r.split("/").pop()||"";return!s.test(n)});return e.length>0?(consola.consola.error(`Files with invalid naming in ${i}: ${e.slice(0,3).join(", ")}${e.length>3?"...":""}`),!1):!0}async function L(t,i,o){const s=new RegExp(o),e=new Set,r=(await getProjectFiles(t,[i.replace(/\/\*\*?$/,"")])).filter(async n=>{const a=pathe.resolve(t,n);try{return(await import("node:fs/promises").then(u=>u.stat(a))).isDirectory()}catch{return!1}});for(const n of await Promise.all(r))if(n){const a=n.split("/").pop()||"";s.test(a)||e.add(n)}return e.size>0?(consola.consola.error(`Directories with invalid naming in ${i}: ${Array.from(e).slice(0,3).join(", ")}`),!1):!0}async function A(t,i){let o=!1;for(const s of i){const{path:e,files:r,directories:n,description:a}=s;consola.consola.start(`Checking naming rule: ${a||e}`),r&&(await D(t,e,r)||(o=!0)),n&&(await L(t,e,n)||(o=!0))}return!o}async function lintStructure(t=process.cwd(),i,o=!1){const{config:s}=await utils.loadConfig({cwd:t,overrides:i?{lint:{structure:i}}:void 0}),e=s.lint?.structure||{},r=s.lint?.fix?.structure||{};let n=!1;return consola.consola.start("Checking project structure..."),e.requiredFiles&&(await v(t,e.requiredFiles,o&&r.createMissingFiles)||(n=!0)),e.requiredDirs&&(await R(t,e.requiredDirs,o&&r.createMissingDirs)||(n=!0)),e.naming&&e.naming.length>0&&(await A(t,e.naming)||(n=!0)),!n}async function lintDocs(t=process.cwd(),i,o=!1){const{config:s}=await utils.loadConfig({cwd:t,overrides:i?{lint:{docs:i}}:void 0}),e=s.lint?.docs||{},r=s.lint?.fix?.docs||{};let n=!1;consola.consola.start("Checking documentation...");const a=[];e.checkReadme&&a.push({type:"README",files:["README.md","README.rst","README.txt","readme.md"],required:!0,fixEnabled:o&&(r.generateReadme??!1),createFile:"README.md"}),e.checkChangelog&&a.push({type:"CHANGELOG",files:["CHANGELOG.md","CHANGELOG.rst","HISTORY.md","changelog.md"],required:!0,fixEnabled:o&&(r.generateChangelog??!1),createFile:"CHANGELOG.md"});for(const{type:u,files:f,required:c,fixEnabled:l,createFile:d}of a){const p=(await Promise.all(f.map(g=>utils.fileExists(pathe.resolve(t,g))))).some(g=>g);if(c&&!p)if(l&&d){consola.consola.start(`Creating ${d}...`);try{await promises.writeFile(pathe.resolve(t,d),"","utf8"),consola.consola.success(`Created ${d}`)}catch(g){consola.consola.error(`Failed to create ${d}:`,g),n=!0}}else consola.consola.error(`No ${u} file found`),n=!0}return!n}async function lintAll(t=process.cwd(),i=!1){const{config:o}=await utils.loadConfig({cwd:t}),s=o.lint||{};consola.consola.start("Running comprehensive project lint...");const e=(await Promise.allSettled([lintProject(t,s.project),lintDependencies(t,s.dependencies,i),lintStructure(t,s.structure,i),lintDocs(t,s.docs,i)])).filter(r=>r.status==="rejected"||r.status==="fulfilled"&&!r.value);return e.length===0?!0:(consola.consola.error(`${e.length} lint check(s) failed`),!1)}async function S(t,i){try{const o=await P__default(["node_modules/*/package.json","node_modules/@*/*/package.json"],{cwd:t,onlyFiles:!0,absolute:!0}),s=[],e=new Set;for(const r of o)try{const n=await pkgTypes.readPackageJSON(r);if(!n.name||e.has(n.name))continue;if(e.add(n.name),n.license){const a=Array.isArray(n.license)?n.license.join(", "):n.license;i.some(u=>a.includes(u))||s.push(`${n.name}: ${a}`)}}catch{}return{hasIssues:s.length>0,invalidLicenses:s}}catch(o){return consola.consola.warn("Failed to check licenses:",o),{hasIssues:!1,invalidLicenses:[]}}}exports.getProjectFiles=getProjectFiles,exports.getStagedFiles=getStagedFiles,exports.lintAll=lintAll,exports.lintDependencies=lintDependencies,exports.lintDocs=lintDocs,exports.lintProject=lintProject,exports.lintStaged=lintStaged,exports.lintStructure=lintStructure;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{execSync as o}from"node:child_process";import{consola as s}from"consola";import{detectPackageManager as y,runScript as h}from"nypm";import{readPackageJSON as k}from"pkg-types";import m from"semver";import{l as b}from"./basis.BrlVPuDi.mjs";function $(t,a,r){if(a.tag)return a.tag;if(a.stable||a.latest)return r.stableTag||"latest";if(m.prerelease(t)){const i=m.prerelease(t);return i&&i[0]||r.defaultTag||"edge"}return r.stableTag||"latest"}async function C(t,a,r){if(a.checkGitClean&&!r.skipTests)try{if(o("git status --porcelain",{cwd:t,encoding:"utf8"}).trim())throw new Error("Working directory is not clean. Commit your changes first.")}catch(i){s.warn("Could not check git status:",i)}if(a.checkTests&&!r.skipTests){s.start("Running tests...");try{a.testCommand?o(a.testCommand,{cwd:t,stdio:"inherit"}):await h("test",{cwd:t,silent:!1})}catch(i){throw s.error("Tests failed"),i}}if(a.buildCommand&&!r.skipBuild){s.start("Building package...");try{a.buildCommand.includes(" ")?o(a.buildCommand,{cwd:t,stdio:"inherit"}):await h(a.buildCommand,{cwd:t,silent:!1})}catch(i){throw s.error("Build failed"),i}}}async function T(t,a){if(a.autoGitPush)try{o("git push",{cwd:t}),a.createGitTag&&o("git push --tags",{cwd:t})}catch(r){s.warn("Failed to push changes:",r)}}async function v(t,a={}){const{config:r}=await b({cwd:t}),i=r.publish||{},f=await k(t),{name:d,version:n}=f;if(!d||!n)throw new Error("Missing name or version in package.json. Please ensure your package.json contains valid 'name' and 'version' fields.");if(!m.valid(n))throw new Error(`Invalid version format in package.json: ${n}. Please use semantic versioning format (e.g., 1.0.0, 2.1.0-alpha.1)`);const p=await y(t),l=p?.command||"npm";await C(t,i,a);const g=$(n,a,i),u=["publish","--tag",g,"--access",a.access||i.access||"public"];(a.registry||i.registry)&&u.push("--registry",a.registry||i.registry||""),a.dryRun&&u.push("--dry-run");const w=`${l} ${u.join(" ")}`;s.start("Publishing package...");try{if(o(w,{cwd:t,stdio:"inherit"}),!a.dryRun){const e=i.defaultTag||"edge";if(g!==e){s.start(`Also publishing to ${e} tag...`);try{let c;p?.name==="yarn"?c=`${l} tag add ${d}@${n} ${e}`:c=`${l} dist-tag add ${d}@${n} ${e}`,o(c,{cwd:t,stdio:"inherit"})}catch(c){s.warn(`Failed to add ${e} tag:`,c)}}await T(t,i)}return{packageName:d,version:n,publishTag:g,dryRun:a.dryRun||!1}}catch(e){throw s.error("Failed to publish package:",e),e}}export{v as p};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{execSync as u}from"node:child_process";import{writeFile as v,mkdir as C}from"node:fs/promises";import{consola as i}from"consola";import j from"fast-glob";import S from"micromatch";import{detectPackageManager as A}from"nypm";import{resolve as m}from"pathe";import{readPackageJSON as b}from"pkg-types";import{l as h,f as y,g as D}from"./basis.BrlVPuDi.mjs";function x(){try{const t=u("git diff --cached --name-only",{encoding:"utf8"}).trim().split(`
|
|
2
|
-
`).filter(Boolean),n=u("git diff --cached --name-only --diff-filter=D",{encoding:"utf8"}),a=new Set(n.trim().split(`
|
|
3
|
-
`).filter(Boolean));return t.filter(r=>!a.has(r))}catch{return[]}}async function $(t,n=["**/*"],a=["node_modules/**","dist/**","build/**",".git/**"]){try{return await j(n,{cwd:t,ignore:a,onlyFiles:!0,dot:!1,absolute:!1})}catch(r){return i.warn("Failed to scan project files:",r),[]}}async function O(t=process.cwd(),n){const{config:a}=await h({cwd:t,overrides:n?{lint:{staged:n}}:void 0}),r=a.lint?.staged||{},e=x();if(e.length===0)return!0;if(Object.keys(r).length===0)return i.warn("No staged lint configuration found. Add lint.staged section to your basis.config.ts"),!0;let c=!1;const s=new Set;for(const[o,g]of Object.entries(r)){const p=e.filter(l=>!s.has(l)&&S.isMatch(l.split("/").pop()||l,o));if(p.length!==0){i.start(`Running staged lint for pattern: ${o}`);try{u(g,{stdio:"inherit",cwd:t});const l=[];for(const d of p)await y(m(t,d))&&l.push(d);l.length>0&&u(`git add ${l.join(" ")}`,{stdio:"inherit",cwd:t}),p.forEach(d=>s.add(d))}catch(l){c=!0,i.error(`Lint pattern '${o}' failed. Please fix the issues and try again:`,l)}}}return!c}async function E(t=process.cwd(),n){const{config:a}=await h({cwd:t,overrides:n?{lint:{project:n}}:void 0}),r=a.lint?.project||{};if(Object.keys(r).length===0)return i.warn("No project lint configuration found. Add lint.project section to your basis.config.ts"),!0;i.start("Running project-wide linting...");let e=!1;for(const[c,s]of Object.entries(r)){i.start(`Running project lint: ${c}`);try{u(s,{stdio:"inherit",cwd:t})}catch(o){e=!0,i.error(`Project lint pattern '${c}' failed. Please fix the issues and try again:`,o)}}return!e}async function F(t=process.cwd(),n,a=!1){const{config:r}=await h({cwd:t,overrides:n?{lint:{dependencies:n}}:void 0}),e=r.lint?.dependencies||{},c=r.lint?.fix?.dependencies||{};let s=!1;try{const o=await b(t),g={...o.dependencies,...o.devDependencies},p=(await A(t))?.name||"npm",l=D(p);if(i.start("Checking dependencies..."),e.blockedPackages&&e.blockedPackages.length>0){const d=Object.keys(g).filter(f=>e.blockedPackages?.includes(f));if(d.length>0)if(a&&c.removeBlocked&&l.remove){i.start(`Removing blocked packages: ${d.join(", ")}`);try{for(const f of d)u(`${l.remove} ${f}`,{cwd:t,stdio:"inherit"});i.success(`Removed ${d.length} blocked packages`)}catch(f){i.error("Failed to remove blocked packages:",f),s=!0}}else i.error(`Blocked packages found: ${d.join(", ")}. Please remove these packages from your dependencies.`),s=!0}if(e.checkOutdated)if(l.outdated)try{u(l.outdated,{cwd:t,stdio:"pipe"})}catch(d){if(a&&c.updateOutdated&&l.update){i.start("Updating outdated dependencies...");try{u(l.update,{cwd:t,stdio:"inherit"}),i.success("Dependencies updated")}catch(f){i.error("Failed to update dependencies:",f),s=!0}}else i.warn("Some dependencies are outdated:",d)}else i.warn(`Outdated check not available for ${p}`);if(e.checkSecurity)if(l.audit)try{u(l.audit,{cwd:t,stdio:"pipe"})}catch(d){if(a&&c.fixSecurity&&l.auditFix){i.start("Fixing security vulnerabilities...");try{u(l.auditFix,{cwd:t,stdio:"inherit"}),i.success("Security fixes applied")}catch(f){i.error("Failed to fix security issues:",f),s=!0}}else i.error("Security vulnerabilities detected:",d),s=!0}else i.warn(`Security audit not available for ${p}`);if(e.allowedLicenses&&e.allowedLicenses.length>0){const{hasIssues:d,invalidLicenses:f}=await B(t,e.allowedLicenses);d&&(i.error("Packages with invalid licenses found:"),f.forEach(k=>i.error(` ${k}`)),s=!0)}}catch(o){i.error("Failed to check dependencies:",o),s=!0}return!s}async function L(t,n,a=!1){if(n.length===0)return!0;const r=(await Promise.all(n.map(async e=>({file:e,exists:await y(m(t,e))})))).filter(e=>!e.exists);if(r.length>0)if(a){i.start(`Creating missing files: ${r.map(e=>e.file).join(", ")}`);try{for(const{file:e}of r)await v(m(t,e),"","utf8");i.success(`Created ${r.length} missing files`)}catch(e){return i.error("Failed to create missing files:",e),!1}}else return r.forEach(({file:e})=>{i.error(`Required file missing: ${e}`)}),!1;return!0}async function M(t,n,a=!1){if(n.length===0)return!0;const r=(await Promise.all(n.map(async e=>({dir:e,exists:await y(m(t,e))})))).filter(e=>!e.exists);if(r.length>0)if(a){i.start(`Creating missing directories: ${r.map(e=>e.dir).join(", ")}`);try{for(const{dir:e}of r)await C(m(t,e),{recursive:!0});i.success(`Created ${r.length} missing directories`)}catch(e){return i.error("Failed to create missing directories:",e),!1}}else return r.forEach(({dir:e})=>{i.error(`Required directory missing: ${e}`)}),!1;return!0}async function q(t,n,a){const r=new RegExp(a),e=(await $(t,[n])).filter(c=>{const s=c.split("/").pop()||"";return!r.test(s)});return e.length>0?(i.error(`Files with invalid naming in ${n}: ${e.slice(0,3).join(", ")}${e.length>3?"...":""}`),!1):!0}async function G(t,n,a){const r=new RegExp(a),e=new Set,c=(await $(t,[n.replace(/\/\*\*?$/,"")])).filter(async s=>{const o=m(t,s);try{return(await import("node:fs/promises").then(g=>g.stat(o))).isDirectory()}catch{return!1}});for(const s of await Promise.all(c))if(s){const o=s.split("/").pop()||"";r.test(o)||e.add(s)}return e.size>0?(i.error(`Directories with invalid naming in ${n}: ${Array.from(e).slice(0,3).join(", ")}`),!1):!0}async function N(t,n){let a=!1;for(const r of n){const{path:e,files:c,directories:s,description:o}=r;i.start(`Checking naming rule: ${o||e}`),c&&(await q(t,e,c)||(a=!0)),s&&(await G(t,e,s)||(a=!0))}return!a}async function P(t=process.cwd(),n,a=!1){const{config:r}=await h({cwd:t,overrides:n?{lint:{structure:n}}:void 0}),e=r.lint?.structure||{},c=r.lint?.fix?.structure||{};let s=!1;return i.start("Checking project structure..."),e.requiredFiles&&(await L(t,e.requiredFiles,a&&c.createMissingFiles)||(s=!0)),e.requiredDirs&&(await M(t,e.requiredDirs,a&&c.createMissingDirs)||(s=!0)),e.naming&&e.naming.length>0&&(await N(t,e.naming)||(s=!0)),!s}async function R(t=process.cwd(),n,a=!1){const{config:r}=await h({cwd:t,overrides:n?{lint:{docs:n}}:void 0}),e=r.lint?.docs||{},c=r.lint?.fix?.docs||{};let s=!1;i.start("Checking documentation...");const o=[];e.checkReadme&&o.push({type:"README",files:["README.md","README.rst","README.txt","readme.md"],required:!0,fixEnabled:a&&(c.generateReadme??!1),createFile:"README.md"}),e.checkChangelog&&o.push({type:"CHANGELOG",files:["CHANGELOG.md","CHANGELOG.rst","HISTORY.md","changelog.md"],required:!0,fixEnabled:a&&(c.generateChangelog??!1),createFile:"CHANGELOG.md"});for(const{type:g,files:p,required:l,fixEnabled:d,createFile:f}of o){const k=(await Promise.all(p.map(w=>y(m(t,w))))).some(w=>w);if(l&&!k)if(d&&f){i.start(`Creating ${f}...`);try{await v(m(t,f),"","utf8"),i.success(`Created ${f}`)}catch(w){i.error(`Failed to create ${f}:`,w),s=!0}}else i.error(`No ${g} file found`),s=!0}return!s}async function H(t=process.cwd(),n=!1){const{config:a}=await h({cwd:t}),r=a.lint||{};i.start("Running comprehensive project lint...");const e=(await Promise.allSettled([E(t,r.project),F(t,r.dependencies,n),P(t,r.structure,n),R(t,r.docs,n)])).filter(c=>c.status==="rejected"||c.status==="fulfilled"&&!c.value);return e.length===0?!0:(i.error(`${e.length} lint check(s) failed`),!1)}async function B(t,n){try{const a=await j(["node_modules/*/package.json","node_modules/@*/*/package.json"],{cwd:t,onlyFiles:!0,absolute:!0}),r=[],e=new Set;for(const c of a)try{const s=await b(c);if(!s.name||e.has(s.name))continue;if(e.add(s.name),s.license){const o=Array.isArray(s.license)?s.license.join(", "):s.license;n.some(g=>o.includes(g))||r.push(`${s.name}: ${o}`)}}catch{}return{hasIssues:r.length>0,invalidLicenses:r}}catch(a){return i.warn("Failed to check licenses:",a),{hasIssues:!1,invalidLicenses:[]}}}export{$ as a,O as b,E as c,F as d,P as e,R as f,x as g,H as l};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const promises=require("node:fs/promises"),c12=require("c12"),config=require("../config.cjs");async function loadConfig(e={}){return await c12.loadConfig({name:"basis",cwd:process.cwd(),...e,defaults:{...config.defaultConfig,...e.defaults}})}async function fileExists(e){try{return await promises.access(e),!0}catch{return!1}}function getPackageManagerCommands(e){switch(e){case"yarn":return{outdated:"yarn outdated --json",audit:"yarn audit --level moderate",execPrefix:"yarn exec",remove:"yarn remove",update:"yarn upgrade",auditFix:"yarn upgrade"};case"pnpm":return{outdated:"pnpm outdated --format table",audit:"pnpm audit --audit-level moderate",execPrefix:"pnpm exec",remove:"pnpm remove",update:"pnpm update",auditFix:"pnpm audit --fix"};case"bun":return{outdated:"bun outdated",audit:null,execPrefix:"bunx",remove:"bun remove",update:"bun update",auditFix:null};case"deno":return{outdated:null,audit:null,execPrefix:"deno task",remove:null,update:null,auditFix:null};default:return{outdated:"npm outdated --json",audit:"npm audit --audit-level moderate",execPrefix:"npx",remove:"npm uninstall",update:"npm update",auditFix:"npm audit fix"}}}exports.fileExists=fileExists,exports.getPackageManagerCommands=getPackageManagerCommands,exports.loadConfig=loadConfig;
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
interface BasisConfig {
|
|
2
|
-
lint?: LintConfig;
|
|
3
|
-
git?: GitConfig;
|
|
4
|
-
version?: VersionConfig;
|
|
5
|
-
publish?: PublishConfig;
|
|
6
|
-
}
|
|
7
|
-
interface LintConfig {
|
|
8
|
-
staged?: Record<string, string>;
|
|
9
|
-
project?: Record<string, string>;
|
|
10
|
-
dependencies?: {
|
|
11
|
-
checkOutdated?: boolean;
|
|
12
|
-
checkSecurity?: boolean;
|
|
13
|
-
allowedLicenses?: string[];
|
|
14
|
-
blockedPackages?: string[];
|
|
15
|
-
};
|
|
16
|
-
structure?: {
|
|
17
|
-
requiredFiles?: string[];
|
|
18
|
-
requiredDirs?: string[];
|
|
19
|
-
naming?: Array<{
|
|
20
|
-
path: string;
|
|
21
|
-
files?: string;
|
|
22
|
-
directories?: string;
|
|
23
|
-
description?: string;
|
|
24
|
-
}>;
|
|
25
|
-
};
|
|
26
|
-
docs?: {
|
|
27
|
-
checkReadme?: boolean;
|
|
28
|
-
checkChangelog?: boolean;
|
|
29
|
-
};
|
|
30
|
-
fix?: {
|
|
31
|
-
/** Enable automatic fixing for all supported issues */
|
|
32
|
-
autoFix?: boolean;
|
|
33
|
-
/** Dependency fix options */
|
|
34
|
-
dependencies?: {
|
|
35
|
-
/** Automatically remove blocked packages */
|
|
36
|
-
removeBlocked?: boolean;
|
|
37
|
-
/** Automatically update outdated dependencies */
|
|
38
|
-
updateOutdated?: boolean;
|
|
39
|
-
/** Attempt to fix security vulnerabilities */
|
|
40
|
-
fixSecurity?: boolean;
|
|
41
|
-
/** Ask for confirmation before making changes */
|
|
42
|
-
interactive?: boolean;
|
|
43
|
-
};
|
|
44
|
-
/** Structure fix options */
|
|
45
|
-
structure?: {
|
|
46
|
-
/** Automatically create missing required files */
|
|
47
|
-
createMissingFiles?: boolean;
|
|
48
|
-
/** Automatically create missing required directories */
|
|
49
|
-
createMissingDirs?: boolean;
|
|
50
|
-
/** Generate file templates for missing files */
|
|
51
|
-
generateTemplates?: boolean;
|
|
52
|
-
};
|
|
53
|
-
/** Documentation fix options */
|
|
54
|
-
docs?: {
|
|
55
|
-
/** Generate README.md template if missing */
|
|
56
|
-
generateReadme?: boolean;
|
|
57
|
-
/** Generate CHANGELOG.md template if missing */
|
|
58
|
-
generateChangelog?: boolean;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
interface GitConfig {
|
|
63
|
-
hooks?: Partial<Record<ValidGitHook, string>>;
|
|
64
|
-
config?: {
|
|
65
|
-
core?: {
|
|
66
|
-
editor?: string;
|
|
67
|
-
autocrlf?: boolean | "input";
|
|
68
|
-
eol?: "lf" | "crlf" | "native";
|
|
69
|
-
ignorecase?: boolean;
|
|
70
|
-
filemode?: boolean;
|
|
71
|
-
bare?: boolean;
|
|
72
|
-
logallrefupdates?: boolean;
|
|
73
|
-
repositoryformatversion?: number;
|
|
74
|
-
sharedrepository?: boolean | "group" | "all" | "world" | "everybody";
|
|
75
|
-
worktree?: string;
|
|
76
|
-
precomposeunicode?: boolean;
|
|
77
|
-
protecthfs?: boolean;
|
|
78
|
-
protectntfs?: boolean;
|
|
79
|
-
};
|
|
80
|
-
user?: {
|
|
81
|
-
name?: string;
|
|
82
|
-
email?: string;
|
|
83
|
-
signingkey?: string;
|
|
84
|
-
};
|
|
85
|
-
init?: {
|
|
86
|
-
defaultBranch?: string;
|
|
87
|
-
};
|
|
88
|
-
branch?: {
|
|
89
|
-
autosetupmerge?: boolean | "always";
|
|
90
|
-
autosetuprebase?: "never" | "local" | "remote" | "always";
|
|
91
|
-
};
|
|
92
|
-
push?: {
|
|
93
|
-
default?: "nothing" | "current" | "upstream" | "simple" | "matching";
|
|
94
|
-
followTags?: boolean;
|
|
95
|
-
autoSetupRemote?: boolean;
|
|
96
|
-
};
|
|
97
|
-
pull?: {
|
|
98
|
-
rebase?: boolean | "preserve" | "merges" | "interactive";
|
|
99
|
-
ff?: boolean | "only";
|
|
100
|
-
};
|
|
101
|
-
merge?: {
|
|
102
|
-
tool?: string;
|
|
103
|
-
conflictstyle?: "merge" | "diff3";
|
|
104
|
-
ff?: boolean | "only";
|
|
105
|
-
log?: boolean | number;
|
|
106
|
-
};
|
|
107
|
-
rebase?: {
|
|
108
|
-
autoSquash?: boolean;
|
|
109
|
-
autoStash?: boolean;
|
|
110
|
-
updateRefs?: boolean;
|
|
111
|
-
};
|
|
112
|
-
fetch?: {
|
|
113
|
-
prune?: boolean;
|
|
114
|
-
pruneTags?: boolean;
|
|
115
|
-
fsckobjects?: boolean;
|
|
116
|
-
};
|
|
117
|
-
remote?: {
|
|
118
|
-
[remoteName: string]: {
|
|
119
|
-
url?: string;
|
|
120
|
-
fetch?: string;
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
diff?: {
|
|
124
|
-
tool?: string;
|
|
125
|
-
algorithm?: "myers" | "minimal" | "patience" | "histogram";
|
|
126
|
-
renames?: boolean | "copy" | "copies";
|
|
127
|
-
mnemonicprefix?: boolean;
|
|
128
|
-
};
|
|
129
|
-
status?: {
|
|
130
|
-
showUntrackedFiles?: "no" | "normal" | "all";
|
|
131
|
-
branch?: boolean;
|
|
132
|
-
short?: boolean;
|
|
133
|
-
};
|
|
134
|
-
commit?: {
|
|
135
|
-
cleanup?: "strip" | "whitespace" | "verbatim" | "scissors" | "default";
|
|
136
|
-
gpgsign?: boolean;
|
|
137
|
-
template?: string;
|
|
138
|
-
verbose?: boolean;
|
|
139
|
-
};
|
|
140
|
-
log?: {
|
|
141
|
-
abbrevCommit?: boolean;
|
|
142
|
-
decorate?: boolean | "short" | "full" | "auto" | "no";
|
|
143
|
-
showSignature?: boolean;
|
|
144
|
-
};
|
|
145
|
-
transfer?: {
|
|
146
|
-
fsckobjects?: boolean;
|
|
147
|
-
};
|
|
148
|
-
receive?: {
|
|
149
|
-
fsckObjects?: boolean;
|
|
150
|
-
};
|
|
151
|
-
gc?: {
|
|
152
|
-
auto?: number;
|
|
153
|
-
autopacklimit?: number;
|
|
154
|
-
autodetach?: boolean;
|
|
155
|
-
};
|
|
156
|
-
alias?: {
|
|
157
|
-
[aliasName: string]: string;
|
|
158
|
-
};
|
|
159
|
-
url?: {
|
|
160
|
-
[pattern: string]: {
|
|
161
|
-
insteadOf?: string;
|
|
162
|
-
pushInsteadOf?: string;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
commitMsg?: CommitMsgConfig;
|
|
167
|
-
autoSetup?: boolean;
|
|
168
|
-
autoInitGit?: boolean;
|
|
169
|
-
skipGitCheck?: boolean;
|
|
170
|
-
force?: boolean;
|
|
171
|
-
}
|
|
172
|
-
interface CommitMsgConfig {
|
|
173
|
-
types?: string[];
|
|
174
|
-
maxLength?: number;
|
|
175
|
-
minLength?: number;
|
|
176
|
-
scopeRequired?: boolean;
|
|
177
|
-
allowedScopes?: string[];
|
|
178
|
-
}
|
|
179
|
-
interface CommitMessage {
|
|
180
|
-
type: string;
|
|
181
|
-
scope?: string;
|
|
182
|
-
description: string;
|
|
183
|
-
body?: string;
|
|
184
|
-
footer?: string;
|
|
185
|
-
isBreaking: boolean;
|
|
186
|
-
}
|
|
187
|
-
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"];
|
|
188
|
-
type ValidGitHook = (typeof VALID_GIT_HOOKS)[number];
|
|
189
|
-
type GitConfigValue = string | number | boolean;
|
|
190
|
-
type GitConfigSection = Record<string, GitConfigValue>;
|
|
191
|
-
type GitConfigData = Record<string, GitConfigSection>;
|
|
192
|
-
interface VersionConfig {
|
|
193
|
-
/** Git tag prefix */
|
|
194
|
-
tagPrefix?: string;
|
|
195
|
-
/** Auto commit version changes */
|
|
196
|
-
autoCommit?: boolean;
|
|
197
|
-
/** Auto create git tag */
|
|
198
|
-
autoTag?: boolean;
|
|
199
|
-
/** Auto push changes to remote */
|
|
200
|
-
autoPush?: boolean;
|
|
201
|
-
/** Prerelease identifier (alpha, beta, rc) */
|
|
202
|
-
prereleaseId?: string;
|
|
203
|
-
/** Commit message template */
|
|
204
|
-
commitMessage?: string;
|
|
205
|
-
}
|
|
206
|
-
interface PublishConfig {
|
|
207
|
-
/** NPM registry URL */
|
|
208
|
-
registry?: string;
|
|
209
|
-
/** Package access level */
|
|
210
|
-
access?: "public" | "private";
|
|
211
|
-
/** Default publish tag (for non-stable releases) */
|
|
212
|
-
defaultTag?: string;
|
|
213
|
-
/** Stable release tag */
|
|
214
|
-
stableTag?: string;
|
|
215
|
-
/** Build command before publish */
|
|
216
|
-
buildCommand?: string;
|
|
217
|
-
/** Test command before publish */
|
|
218
|
-
testCommand?: string;
|
|
219
|
-
/** Check git working directory is clean */
|
|
220
|
-
checkGitClean?: boolean;
|
|
221
|
-
/** Run tests before publish */
|
|
222
|
-
checkTests?: boolean;
|
|
223
|
-
/** Auto push git changes after publish */
|
|
224
|
-
autoGitPush?: boolean;
|
|
225
|
-
/** Create git tag after publish */
|
|
226
|
-
createGitTag?: boolean;
|
|
227
|
-
}
|
|
228
|
-
interface InitOptions {
|
|
229
|
-
force?: boolean;
|
|
230
|
-
skipGitCheck?: boolean;
|
|
231
|
-
skipInstall?: boolean;
|
|
232
|
-
}
|
|
233
|
-
interface VersionOptions {
|
|
234
|
-
version?: string;
|
|
235
|
-
preid?: string;
|
|
236
|
-
prerelease?: boolean;
|
|
237
|
-
major?: boolean;
|
|
238
|
-
minor?: boolean;
|
|
239
|
-
patch?: boolean;
|
|
240
|
-
tag?: string;
|
|
241
|
-
message?: string;
|
|
242
|
-
}
|
|
243
|
-
interface PublishOptions {
|
|
244
|
-
tag?: string;
|
|
245
|
-
stable?: boolean;
|
|
246
|
-
latest?: boolean;
|
|
247
|
-
dryRun?: boolean;
|
|
248
|
-
access?: "public" | "private";
|
|
249
|
-
registry?: string;
|
|
250
|
-
skipBuild?: boolean;
|
|
251
|
-
skipTests?: boolean;
|
|
252
|
-
}
|
|
253
|
-
interface VersionUpdateResult {
|
|
254
|
-
oldVersion: string;
|
|
255
|
-
newVersion: string;
|
|
256
|
-
tagName?: string;
|
|
257
|
-
}
|
|
258
|
-
interface PublishResult {
|
|
259
|
-
packageName: string;
|
|
260
|
-
version: string;
|
|
261
|
-
publishTag: string;
|
|
262
|
-
dryRun: boolean;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Define a Basis configuration
|
|
267
|
-
*/
|
|
268
|
-
declare function defineBasisConfig(config: BasisConfig): BasisConfig;
|
|
269
|
-
/**
|
|
270
|
-
* Default configuration
|
|
271
|
-
*/
|
|
272
|
-
declare const defaultConfig: BasisConfig;
|
|
273
|
-
|
|
274
|
-
export { defineBasisConfig as d, defaultConfig as e, VALID_GIT_HOOKS as g };
|
|
275
|
-
export type { BasisConfig as B, CommitMessage as C, GitConfig as G, InitOptions as I, LintConfig as L, PublishOptions as P, VersionOptions as V, VersionUpdateResult as a, PublishResult as b, GitConfigData as c, CommitMsgConfig as f, ValidGitHook as h, GitConfigValue as i, GitConfigSection as j, VersionConfig as k, PublishConfig as l };
|