@funish/basis 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +390 -0
- package/dist/chunks/add.cjs +1 -0
- package/dist/chunks/add.mjs +1 -0
- package/dist/chunks/config.cjs +1 -0
- package/dist/chunks/config.mjs +1 -0
- package/dist/chunks/githooks.cjs +1 -0
- package/dist/chunks/githooks.mjs +1 -0
- package/dist/chunks/init.cjs +1 -0
- package/dist/chunks/init.mjs +1 -0
- package/dist/chunks/install.cjs +1 -0
- package/dist/chunks/install.mjs +1 -0
- package/dist/chunks/lint.cjs +1 -0
- package/dist/chunks/lint.mjs +1 -0
- package/dist/chunks/publish.cjs +1 -0
- package/dist/chunks/publish.mjs +1 -0
- package/dist/chunks/remove.cjs +1 -0
- package/dist/chunks/remove.mjs +1 -0
- package/dist/chunks/run.cjs +1 -0
- package/dist/chunks/run.mjs +1 -0
- package/dist/chunks/version.cjs +1 -0
- package/dist/chunks/version.mjs +1 -0
- package/dist/cli.cjs +2 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +2 -0
- package/dist/config.cjs +1 -0
- package/dist/config.d.cts +1 -0
- package/dist/config.d.mts +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +89 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.mjs +1 -0
- package/dist/shared/basis.ByJ8R9TE.cjs +1 -0
- package/dist/shared/basis.C0E7mwQ6.mjs +1 -0
- package/dist/shared/basis.C5wlo6IO.mjs +1 -0
- package/dist/shared/basis.CBZIV3-V.mjs +19 -0
- package/dist/shared/basis.CSSuyvpq.cjs +1 -0
- package/dist/shared/basis.CgpyxNW3.cjs +1 -0
- package/dist/shared/basis.D57HxVvD.cjs +4 -0
- package/dist/shared/basis.DeKfEQsQ.cjs +5 -0
- package/dist/shared/basis.DweCjqFb.cjs +19 -0
- package/dist/shared/basis.O4so-uuj.mjs +5 -0
- package/dist/shared/basis.dc3ybBoz.mjs +1 -0
- package/dist/shared/basis.iRZ1Ylu8.d.cts +127 -0
- package/dist/shared/basis.iRZ1Ylu8.d.mts +127 -0
- package/dist/shared/basis.iRZ1Ylu8.d.ts +127 -0
- package/dist/shared/basis.rDVxD7qf.mjs +4 -0
- package/package.json +77 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
interface BasisConfig {
|
|
2
|
+
lint?: LintConfig;
|
|
3
|
+
githooks?: GitHooksConfig;
|
|
4
|
+
packageManager?: PackageManagerConfig;
|
|
5
|
+
version?: VersionConfig;
|
|
6
|
+
publish?: PublishConfig;
|
|
7
|
+
}
|
|
8
|
+
interface LintConfig {
|
|
9
|
+
staged?: Record<string, string>;
|
|
10
|
+
commitMsg?: {
|
|
11
|
+
types?: string[];
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
minLength?: number;
|
|
14
|
+
scopeRequired?: boolean;
|
|
15
|
+
allowedScopes?: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
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"];
|
|
19
|
+
type ValidGitHook = (typeof VALID_GIT_HOOKS)[number];
|
|
20
|
+
interface GitHooksConfig extends Partial<Record<ValidGitHook, string>> {
|
|
21
|
+
/** Whether to automatically initialize git repository if not found */
|
|
22
|
+
autoInitGit?: boolean;
|
|
23
|
+
/** Whether to skip git command availability check */
|
|
24
|
+
skipGitCheck?: boolean;
|
|
25
|
+
/** Force operation even if git is not available */
|
|
26
|
+
force?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface PackageManagerConfig {
|
|
29
|
+
/** Preferred package manager (aligned with nypm support) */
|
|
30
|
+
preferred?: "npm" | "yarn" | "pnpm" | "bun" | "deno";
|
|
31
|
+
/** Auto-detect package manager from project */
|
|
32
|
+
autoDetect?: boolean;
|
|
33
|
+
/** NPM registry URL */
|
|
34
|
+
registry?: string;
|
|
35
|
+
}
|
|
36
|
+
interface VersionConfig {
|
|
37
|
+
/** Git tag prefix */
|
|
38
|
+
tagPrefix?: string;
|
|
39
|
+
/** Auto commit version changes */
|
|
40
|
+
autoCommit?: boolean;
|
|
41
|
+
/** Auto create git tag */
|
|
42
|
+
autoTag?: boolean;
|
|
43
|
+
/** Auto push changes to remote */
|
|
44
|
+
autoPush?: boolean;
|
|
45
|
+
/** Prerelease identifier (alpha, beta, rc) */
|
|
46
|
+
prereleaseId?: string;
|
|
47
|
+
/** Commit message template */
|
|
48
|
+
commitMessage?: string;
|
|
49
|
+
}
|
|
50
|
+
interface PublishConfig {
|
|
51
|
+
/** NPM registry URL */
|
|
52
|
+
registry?: string;
|
|
53
|
+
/** Package access level */
|
|
54
|
+
access?: "public" | "private";
|
|
55
|
+
/** Default publish tag (for non-stable releases) */
|
|
56
|
+
defaultTag?: string;
|
|
57
|
+
/** Stable release tag */
|
|
58
|
+
stableTag?: string;
|
|
59
|
+
/** Build command before publish */
|
|
60
|
+
buildCommand?: string;
|
|
61
|
+
/** Test command before publish */
|
|
62
|
+
testCommand?: string;
|
|
63
|
+
/** Check git working directory is clean */
|
|
64
|
+
checkGitClean?: boolean;
|
|
65
|
+
/** Run tests before publish */
|
|
66
|
+
checkTests?: boolean;
|
|
67
|
+
/** Auto push git changes after publish */
|
|
68
|
+
autoGitPush?: boolean;
|
|
69
|
+
/** Create git tag after publish */
|
|
70
|
+
createGitTag?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface CommitMessage {
|
|
73
|
+
type: string;
|
|
74
|
+
scope?: string;
|
|
75
|
+
description: string;
|
|
76
|
+
body?: string;
|
|
77
|
+
footer?: string;
|
|
78
|
+
isBreaking: boolean;
|
|
79
|
+
}
|
|
80
|
+
interface InitOptions {
|
|
81
|
+
force?: boolean;
|
|
82
|
+
skipGitCheck?: boolean;
|
|
83
|
+
skipInstall?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface VersionOptions {
|
|
86
|
+
version?: string;
|
|
87
|
+
preid?: string;
|
|
88
|
+
prerelease?: boolean;
|
|
89
|
+
major?: boolean;
|
|
90
|
+
minor?: boolean;
|
|
91
|
+
patch?: boolean;
|
|
92
|
+
tag?: string;
|
|
93
|
+
message?: string;
|
|
94
|
+
}
|
|
95
|
+
interface PublishOptions {
|
|
96
|
+
tag?: string;
|
|
97
|
+
stable?: boolean;
|
|
98
|
+
latest?: boolean;
|
|
99
|
+
dryRun?: boolean;
|
|
100
|
+
access?: "public" | "private";
|
|
101
|
+
registry?: string;
|
|
102
|
+
skipBuild?: boolean;
|
|
103
|
+
skipTests?: boolean;
|
|
104
|
+
}
|
|
105
|
+
interface VersionUpdateResult {
|
|
106
|
+
oldVersion: string;
|
|
107
|
+
newVersion: string;
|
|
108
|
+
tagName?: string;
|
|
109
|
+
}
|
|
110
|
+
interface PublishResult {
|
|
111
|
+
packageName: string;
|
|
112
|
+
version: string;
|
|
113
|
+
publishTag: string;
|
|
114
|
+
dryRun: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Define a Basis configuration
|
|
119
|
+
*/
|
|
120
|
+
declare function defineBasisConfig(config: BasisConfig): BasisConfig;
|
|
121
|
+
/**
|
|
122
|
+
* Default configuration
|
|
123
|
+
*/
|
|
124
|
+
declare const defaultConfig: BasisConfig;
|
|
125
|
+
|
|
126
|
+
export { defaultConfig as c, defineBasisConfig as d, VALID_GIT_HOOKS as e };
|
|
127
|
+
export type { BasisConfig as B, CommitMessage as C, GitHooksConfig as G, InitOptions as I, LintConfig as L, PublishOptions as P, VersionOptions as V, PublishResult as a, VersionUpdateResult as b, ValidGitHook as f, PackageManagerConfig as g, VersionConfig as h, PublishConfig as i };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
interface BasisConfig {
|
|
2
|
+
lint?: LintConfig;
|
|
3
|
+
githooks?: GitHooksConfig;
|
|
4
|
+
packageManager?: PackageManagerConfig;
|
|
5
|
+
version?: VersionConfig;
|
|
6
|
+
publish?: PublishConfig;
|
|
7
|
+
}
|
|
8
|
+
interface LintConfig {
|
|
9
|
+
staged?: Record<string, string>;
|
|
10
|
+
commitMsg?: {
|
|
11
|
+
types?: string[];
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
minLength?: number;
|
|
14
|
+
scopeRequired?: boolean;
|
|
15
|
+
allowedScopes?: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
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"];
|
|
19
|
+
type ValidGitHook = (typeof VALID_GIT_HOOKS)[number];
|
|
20
|
+
interface GitHooksConfig extends Partial<Record<ValidGitHook, string>> {
|
|
21
|
+
/** Whether to automatically initialize git repository if not found */
|
|
22
|
+
autoInitGit?: boolean;
|
|
23
|
+
/** Whether to skip git command availability check */
|
|
24
|
+
skipGitCheck?: boolean;
|
|
25
|
+
/** Force operation even if git is not available */
|
|
26
|
+
force?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface PackageManagerConfig {
|
|
29
|
+
/** Preferred package manager (aligned with nypm support) */
|
|
30
|
+
preferred?: "npm" | "yarn" | "pnpm" | "bun" | "deno";
|
|
31
|
+
/** Auto-detect package manager from project */
|
|
32
|
+
autoDetect?: boolean;
|
|
33
|
+
/** NPM registry URL */
|
|
34
|
+
registry?: string;
|
|
35
|
+
}
|
|
36
|
+
interface VersionConfig {
|
|
37
|
+
/** Git tag prefix */
|
|
38
|
+
tagPrefix?: string;
|
|
39
|
+
/** Auto commit version changes */
|
|
40
|
+
autoCommit?: boolean;
|
|
41
|
+
/** Auto create git tag */
|
|
42
|
+
autoTag?: boolean;
|
|
43
|
+
/** Auto push changes to remote */
|
|
44
|
+
autoPush?: boolean;
|
|
45
|
+
/** Prerelease identifier (alpha, beta, rc) */
|
|
46
|
+
prereleaseId?: string;
|
|
47
|
+
/** Commit message template */
|
|
48
|
+
commitMessage?: string;
|
|
49
|
+
}
|
|
50
|
+
interface PublishConfig {
|
|
51
|
+
/** NPM registry URL */
|
|
52
|
+
registry?: string;
|
|
53
|
+
/** Package access level */
|
|
54
|
+
access?: "public" | "private";
|
|
55
|
+
/** Default publish tag (for non-stable releases) */
|
|
56
|
+
defaultTag?: string;
|
|
57
|
+
/** Stable release tag */
|
|
58
|
+
stableTag?: string;
|
|
59
|
+
/** Build command before publish */
|
|
60
|
+
buildCommand?: string;
|
|
61
|
+
/** Test command before publish */
|
|
62
|
+
testCommand?: string;
|
|
63
|
+
/** Check git working directory is clean */
|
|
64
|
+
checkGitClean?: boolean;
|
|
65
|
+
/** Run tests before publish */
|
|
66
|
+
checkTests?: boolean;
|
|
67
|
+
/** Auto push git changes after publish */
|
|
68
|
+
autoGitPush?: boolean;
|
|
69
|
+
/** Create git tag after publish */
|
|
70
|
+
createGitTag?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface CommitMessage {
|
|
73
|
+
type: string;
|
|
74
|
+
scope?: string;
|
|
75
|
+
description: string;
|
|
76
|
+
body?: string;
|
|
77
|
+
footer?: string;
|
|
78
|
+
isBreaking: boolean;
|
|
79
|
+
}
|
|
80
|
+
interface InitOptions {
|
|
81
|
+
force?: boolean;
|
|
82
|
+
skipGitCheck?: boolean;
|
|
83
|
+
skipInstall?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface VersionOptions {
|
|
86
|
+
version?: string;
|
|
87
|
+
preid?: string;
|
|
88
|
+
prerelease?: boolean;
|
|
89
|
+
major?: boolean;
|
|
90
|
+
minor?: boolean;
|
|
91
|
+
patch?: boolean;
|
|
92
|
+
tag?: string;
|
|
93
|
+
message?: string;
|
|
94
|
+
}
|
|
95
|
+
interface PublishOptions {
|
|
96
|
+
tag?: string;
|
|
97
|
+
stable?: boolean;
|
|
98
|
+
latest?: boolean;
|
|
99
|
+
dryRun?: boolean;
|
|
100
|
+
access?: "public" | "private";
|
|
101
|
+
registry?: string;
|
|
102
|
+
skipBuild?: boolean;
|
|
103
|
+
skipTests?: boolean;
|
|
104
|
+
}
|
|
105
|
+
interface VersionUpdateResult {
|
|
106
|
+
oldVersion: string;
|
|
107
|
+
newVersion: string;
|
|
108
|
+
tagName?: string;
|
|
109
|
+
}
|
|
110
|
+
interface PublishResult {
|
|
111
|
+
packageName: string;
|
|
112
|
+
version: string;
|
|
113
|
+
publishTag: string;
|
|
114
|
+
dryRun: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Define a Basis configuration
|
|
119
|
+
*/
|
|
120
|
+
declare function defineBasisConfig(config: BasisConfig): BasisConfig;
|
|
121
|
+
/**
|
|
122
|
+
* Default configuration
|
|
123
|
+
*/
|
|
124
|
+
declare const defaultConfig: BasisConfig;
|
|
125
|
+
|
|
126
|
+
export { defaultConfig as c, defineBasisConfig as d, VALID_GIT_HOOKS as e };
|
|
127
|
+
export type { BasisConfig as B, CommitMessage as C, GitHooksConfig as G, InitOptions as I, LintConfig as L, PublishOptions as P, VersionOptions as V, PublishResult as a, VersionUpdateResult as b, ValidGitHook as f, PackageManagerConfig as g, VersionConfig as h, PublishConfig as i };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{execSync as m}from"node:child_process";import{existsSync as $,readFileSync as v}from"node:fs";import{consola as d}from"consola";import w from"micromatch";import{resolve as M}from"pathe";import{l as u}from"./basis.C0E7mwQ6.mjs";const S=["feat","fix","docs","style","refactor","perf","test","build","ci","chore","revert"];function p(o){const r=o.trim().split(`
|
|
2
|
+
`),t=r[0].match(/^(\w+)(\(([^)]+)\))?(!)?:\s*(.+)$/);if(!t)return null;const[,l,,s,c,e]=t,a=r.slice(1).find(i=>i.trim())?.trim(),n=r.slice(-1)[0]?.trim();return{type:l,scope:s,description:e,body:a,footer:n,isBreaking:!!c||o.includes("BREAKING CHANGE:")}}function g(o,r={}){const t=[],{types:l=S,maxLength:s=72,minLength:c=10,scopeRequired:e=!1,allowedScopes:a=[]}=r,n=p(o);if(!n)return{valid:!1,errors:["Invalid commit format. Expected: type(scope): description"]};l.includes(n.type)||t.push(`Invalid type '${n.type}'. Allowed: ${l.join(", ")}`);const i=o.split(`
|
|
3
|
+
`)[0];return i.length>s&&t.push(`Header too long (${i.length}). Max: ${s}`),i.length<c&&t.push(`Header too short (${i.length}). Min: ${c}`),e&&!n.scope&&t.push("Scope is required"),n.scope&&a.length>0&&!a.includes(n.scope)&&t.push(`Invalid scope '${n.scope}'. Allowed: ${a.join(", ")}`),{valid:t.length===0,errors:t}}function h(){try{return m("git diff --cached --name-only",{encoding:"utf8"}).trim().split(`
|
|
4
|
+
`).filter(Boolean)}catch{return[]}}async function x(o=process.cwd(),r){const{config:t}=await u({cwd:o,overrides:r?{lint:{staged:r}}:void 0}),l=t.lint?.staged||{},s=h();if(s.length===0)return d.info("No staged files to lint"),!0;if(Object.keys(l).length===0)return d.warn("No staged lint configuration found"),!0;let c=!1;const e=new Set;for(const[a,n]of Object.entries(l)){const i=s.filter(f=>!e.has(f)&&w.isMatch(f.split("/").pop()||f,a));if(i.length!==0){d.start(`Linting ${i.length} files: ${a}`);try{const f=`${n} ${i.join(" ")}`;m(f,{stdio:"inherit",cwd:o}),m(`git add ${i.join(" ")}`,{stdio:"inherit",cwd:o}),i.forEach(y=>e.add(y)),d.success(`\u2713 ${a}`)}catch(f){c=!0,d.error(`\u2717 ${a} failed:`,f)}}}return!c}async function C(o=process.cwd(),r){const{config:t}=await u({cwd:o,overrides:r?{lint:{commitMsg:r}}:void 0}),l=t.lint?.commitMsg||{};let s;try{const e=M(".git/COMMIT_EDITMSG");$(e)?s=v(e,"utf8"):s=m("git log -1 --pretty=%B",{encoding:"utf8"}).trim()}catch(e){return d.error("\u2717 Failed to read commit message:",e),!1}const c=g(s,l);return c.valid?(d.success("\u2713 Commit message is valid"),!0):(d.error("\u2717 Invalid commit message:"),c.errors.forEach(e=>d.error(` ${e}`)),!1)}export{C as a,h as g,x as l,p,g as v};
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@funish/basis",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A unified development toolkit with CLI for package management, versioning, publishing, linting, and git hooks management for JavaScript/TypeScript projects.",
|
|
5
|
+
"main": "dist/index.mjs",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"templates"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"basis": "dist/cli.mjs"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.mjs",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./config": {
|
|
20
|
+
"import": "./dist/config.mjs",
|
|
21
|
+
"require": "./dist/config.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/funish/basis.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"basis",
|
|
30
|
+
"development-toolkit",
|
|
31
|
+
"cli",
|
|
32
|
+
"package-management",
|
|
33
|
+
"version-management",
|
|
34
|
+
"npm-publish",
|
|
35
|
+
"semantic-versioning",
|
|
36
|
+
"linting",
|
|
37
|
+
"git-hooks",
|
|
38
|
+
"typescript",
|
|
39
|
+
"javascript",
|
|
40
|
+
"developer-experience",
|
|
41
|
+
"code-quality",
|
|
42
|
+
"modern-development",
|
|
43
|
+
"unjs",
|
|
44
|
+
"nypm",
|
|
45
|
+
"semver",
|
|
46
|
+
"citty",
|
|
47
|
+
"consola",
|
|
48
|
+
"c12"
|
|
49
|
+
],
|
|
50
|
+
"author": {
|
|
51
|
+
"name": "Funish",
|
|
52
|
+
"email": "official@funish.net",
|
|
53
|
+
"url": "https://funish.net/"
|
|
54
|
+
},
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/funish/basis/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/funish/basis#readme",
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"c12": "3.0.4",
|
|
62
|
+
"citty": "0.1.6",
|
|
63
|
+
"consola": "3.4.2",
|
|
64
|
+
"micromatch": "4.0.8",
|
|
65
|
+
"nypm": "0.6.0",
|
|
66
|
+
"pathe": "2.0.3",
|
|
67
|
+
"pkg-types": "2.1.0",
|
|
68
|
+
"semver": "7.7.2"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/micromatch": "4.0.9",
|
|
72
|
+
"@types/semver": "7.7.0"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"dev": "unbuild --stub"
|
|
76
|
+
}
|
|
77
|
+
}
|