@funish/basis 0.2.6 → 0.2.7
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/dist/_chunks/common-ImpHew-F-C_Vy_bWl.mjs +563 -0
- package/dist/_chunks/config-DlKQJJuJ.mjs +1 -0
- package/dist/_chunks/dist-DmC4QnLo-DOtdNTJ9.mjs +1 -0
- package/dist/_chunks/jiti-4UP3iYSN.mjs +1 -0
- package/dist/_chunks/jiti-BTGRq7zm-CIyI5D4F.mjs +1 -0
- package/dist/_chunks/json5-jlDEA_LV-COBYYABw.mjs +1 -0
- package/dist/_chunks/json5-yz56pVhc.mjs +1 -0
- package/dist/_chunks/jsonc-BQ0-fIlR.mjs +1 -0
- package/dist/_chunks/jsonc-h2mYQXaC-DrYrX9nH.mjs +1 -0
- package/dist/_chunks/ohash-CBmXOb0i.mjs +1 -0
- package/dist/_chunks/ohash-auviw4oE-C1rS-sj5.mjs +1 -0
- package/dist/_chunks/prompt-B0wRZcxM.mjs +1 -0
- package/dist/_chunks/prompt-B56gTa4S-DU9z28wS-C5xwSzir.mjs +1 -0
- package/dist/_chunks/prompt-DWoeycZC-CrPLiZ-7.mjs +1 -0
- package/dist/_chunks/resolver-j7HY1N36-CYXyUckt-KaY2bzL2.mjs +1 -0
- package/dist/_chunks/rolldown-runtime-coR7_hWt.mjs +1 -0
- package/dist/_chunks/toml-Db_vu9L2.mjs +1 -0
- package/dist/_chunks/toml-DpopYhMQ-Cm2FvyAB.mjs +1 -0
- package/dist/_chunks/trace-DE8F1ZUa-BjFwYDv5.mjs +1 -0
- package/dist/_chunks/tsc-DYjBCyQo-W841VDnt.mjs +1 -0
- package/dist/_chunks/{types-D9xRZRDc.d.mts → types-D97hRU-z.d.mts} +7 -6
- package/dist/_chunks/vendor/common-BKG-EppI.mjs +352 -0
- package/dist/_chunks/vendor/common-BpqHhQqH.d.mts +359 -0
- package/dist/_chunks/yaml-Bk1o9q2C.mjs +1 -0
- package/dist/_chunks/yaml-rm6ZZAQq-BzQnHREY.mjs +1 -0
- package/dist/cli.mjs +19 -9
- package/dist/commands/fmt.mjs +1 -1
- package/dist/commands/lint.mjs +1 -1
- package/dist/config.d.mts +6968 -6
- package/dist/config.mjs +1 -1
- package/dist/index.d.mts +2 -1
- package/package.json +5 -4
- package/dist/_chunks/config-D9BuZxZJ.mjs +0 -1
- package/dist/commands/check.d.mts +0 -2
- package/dist/commands/check.mjs +0 -1
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { DownloadTemplateOptions } from "giget";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
|
|
4
|
+
interface GitRemote {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
name?: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
fetch?: string;
|
|
9
|
+
}
|
|
10
|
+
interface GitBranch {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
remote?: string;
|
|
13
|
+
merge?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
rebase?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface GitCoreConfig {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
interface GitConfigUser {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
name?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
}
|
|
25
|
+
interface GitConfig {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
core?: GitCoreConfig;
|
|
28
|
+
user?: GitConfigUser;
|
|
29
|
+
remote?: Record<string, GitRemote>;
|
|
30
|
+
branch?: Record<string, GitBranch>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Defines a git config object.
|
|
34
|
+
*/
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/types.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* Jiti instance options
|
|
39
|
+
*/
|
|
40
|
+
interface JitiOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Filesystem source cache
|
|
43
|
+
*
|
|
44
|
+
* An string can be passed to set the custom cache directory.
|
|
45
|
+
*
|
|
46
|
+
* By default (when set to `true`), jiti uses
|
|
47
|
+
* `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/jiti`.
|
|
48
|
+
*
|
|
49
|
+
* This option can also be disabled using
|
|
50
|
+
* `JITI_FS_CACHE=false` environment variable.
|
|
51
|
+
*
|
|
52
|
+
* **Note:** It is recommended to keep this option
|
|
53
|
+
* enabled for better performance.
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
fsCache?: boolean | string;
|
|
58
|
+
/**
|
|
59
|
+
* Rebuild the filesystem source cache
|
|
60
|
+
*
|
|
61
|
+
* This option can also be enabled using
|
|
62
|
+
* `JITI_REBUILD_FS_CACHE=true` environment variable.
|
|
63
|
+
*
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
rebuildFsCache?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Use the {@linkcode fsCache} option.
|
|
69
|
+
*
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
cache?: boolean | string;
|
|
73
|
+
/**
|
|
74
|
+
* Runtime module cache
|
|
75
|
+
*
|
|
76
|
+
* Disabling allows editing code and importing same module multiple times.
|
|
77
|
+
*
|
|
78
|
+
* When enabled, jiti integrates with Node.js native CommonJS cache store.
|
|
79
|
+
*
|
|
80
|
+
* This option can also be disabled using
|
|
81
|
+
* `JITI_MODULE_CACHE=false` environment variable.
|
|
82
|
+
*
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
moduleCache?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use the {@linkcode moduleCache} option.
|
|
88
|
+
*
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
requireCache?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Custom transform function
|
|
94
|
+
*/
|
|
95
|
+
transform?: (opts: TransformOptions) => TransformResult;
|
|
96
|
+
/**
|
|
97
|
+
* Enable verbose debugging.
|
|
98
|
+
*
|
|
99
|
+
* Can also be enabled using `JITI_DEBUG=1` environment variable.
|
|
100
|
+
*
|
|
101
|
+
* @default false
|
|
102
|
+
*/
|
|
103
|
+
debug?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Enable sourcemaps for transformed code.
|
|
106
|
+
*
|
|
107
|
+
* Can also be disabled using `JITI_SOURCE_MAPS=0` environment variable.
|
|
108
|
+
*
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
sourceMaps?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Jiti combines module exports with the `default` export using an
|
|
114
|
+
* internal Proxy to improve compatibility with mixed CJS/ESM usage.
|
|
115
|
+
* You can check the current implementation
|
|
116
|
+
* {@link https://github.com/unjs/jiti/blob/main/src/utils.ts#L105 here}.
|
|
117
|
+
*
|
|
118
|
+
* Can be disabled using `JITI_INTEROP_DEFAULT=0` environment variable.
|
|
119
|
+
*
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
interopDefault?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Jiti hard source cache version.
|
|
125
|
+
*
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
cacheVersion?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Supported extensions to resolve.
|
|
131
|
+
*
|
|
132
|
+
* @default [".js", ".mjs", ".cjs", ".ts", ".tsx", ".mts", ".cts", ".mtsx", ".ctsx", ".json"]
|
|
133
|
+
*/
|
|
134
|
+
extensions?: string[];
|
|
135
|
+
/**
|
|
136
|
+
* Transform options
|
|
137
|
+
*/
|
|
138
|
+
transformOptions?: Omit<TransformOptions, "source">;
|
|
139
|
+
/**
|
|
140
|
+
* Resolve aliases
|
|
141
|
+
*
|
|
142
|
+
* You can use `JITI_ALIAS` environment variable to set aliases as
|
|
143
|
+
* a JSON string.
|
|
144
|
+
*
|
|
145
|
+
* @default {}
|
|
146
|
+
*/
|
|
147
|
+
alias?: Record<string, string>;
|
|
148
|
+
/**
|
|
149
|
+
* List of modules (within `node_modules`) to always use native
|
|
150
|
+
* require/import for them.
|
|
151
|
+
*
|
|
152
|
+
* You can use `JITI_NATIVE_MODULES` environment variable to set
|
|
153
|
+
* native modules as a JSON string.
|
|
154
|
+
*
|
|
155
|
+
* @default []
|
|
156
|
+
*/
|
|
157
|
+
nativeModules?: string[];
|
|
158
|
+
/**
|
|
159
|
+
* List of modules (within `node_modules`) to transform them
|
|
160
|
+
* regardless of syntax.
|
|
161
|
+
*
|
|
162
|
+
* You can use `JITI_TRANSFORM_MODULES` environment variable to set
|
|
163
|
+
* transform modules as a JSON string.
|
|
164
|
+
*
|
|
165
|
+
* @default []
|
|
166
|
+
*/
|
|
167
|
+
transformModules?: string[];
|
|
168
|
+
/**
|
|
169
|
+
* Parent module's {@linkcode ImportMeta | import.meta} context to use
|
|
170
|
+
* for ESM resolution.
|
|
171
|
+
*
|
|
172
|
+
* (Only used for `jiti/native` import)
|
|
173
|
+
*/
|
|
174
|
+
importMeta?: ImportMeta;
|
|
175
|
+
/**
|
|
176
|
+
* Try to use native require and import without jiti transformations first.
|
|
177
|
+
*
|
|
178
|
+
* Enabled if Bun is detected.
|
|
179
|
+
*
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
tryNative?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Enable JSX support Enable JSX support using
|
|
185
|
+
* {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx | `@babel/plugin-transform-react-jsx`}.
|
|
186
|
+
*
|
|
187
|
+
* You can also use `JITI_JSX=1` environment variable to enable JSX support.
|
|
188
|
+
*
|
|
189
|
+
* @default false
|
|
190
|
+
*/
|
|
191
|
+
jsx?: boolean | JSXOptions;
|
|
192
|
+
}
|
|
193
|
+
interface TransformOptions {
|
|
194
|
+
source: string;
|
|
195
|
+
filename?: string;
|
|
196
|
+
ts?: boolean;
|
|
197
|
+
retainLines?: boolean;
|
|
198
|
+
interopDefault?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
202
|
+
async?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* @default false
|
|
205
|
+
*/
|
|
206
|
+
jsx?: boolean | JSXOptions;
|
|
207
|
+
babel?: Record<string, any>;
|
|
208
|
+
}
|
|
209
|
+
interface TransformResult {
|
|
210
|
+
code: string;
|
|
211
|
+
error?: any;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options | Reference}
|
|
215
|
+
*/
|
|
216
|
+
interface JSXOptions {
|
|
217
|
+
throwIfNamespace?: boolean;
|
|
218
|
+
runtime?: "classic" | "automatic";
|
|
219
|
+
importSource?: string;
|
|
220
|
+
pragma?: string;
|
|
221
|
+
pragmaFrag?: string;
|
|
222
|
+
useBuiltIns?: boolean;
|
|
223
|
+
useSpread?: boolean;
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ../../node_modules/.pnpm/c12@4.0.0-beta.3_jiti@2.6.1/node_modules/c12/dist/index.d.mts
|
|
227
|
+
//#region src/dotenv.d.ts
|
|
228
|
+
interface DotenvOptions {
|
|
229
|
+
/**
|
|
230
|
+
* The project root directory (either absolute or relative to the current working directory).
|
|
231
|
+
*
|
|
232
|
+
* Defaults to `options.cwd` in `loadConfig` context, or `process.cwd()` when used as standalone.
|
|
233
|
+
*/
|
|
234
|
+
cwd?: string;
|
|
235
|
+
/**
|
|
236
|
+
* What file or files to look in for environment variables (either absolute or relative
|
|
237
|
+
* to the current working directory). For example, `.env`.
|
|
238
|
+
* With the array type, the order enforce the env loading priority (last one overrides).
|
|
239
|
+
*/
|
|
240
|
+
fileName?: string | string[];
|
|
241
|
+
/**
|
|
242
|
+
* Whether to interpolate variables within .env.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```env
|
|
246
|
+
* BASE_DIR="/test"
|
|
247
|
+
* # resolves to "/test/further"
|
|
248
|
+
* ANOTHER_DIR="${BASE_DIR}/further"
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
interpolate?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* An object describing environment variables (key, value pairs).
|
|
254
|
+
*/
|
|
255
|
+
env?: NodeJS.ProcessEnv;
|
|
256
|
+
/**
|
|
257
|
+
* Resolve `_FILE` suffixed environment variables by reading the file at the
|
|
258
|
+
* specified path and assigning its trimmed content to the base key.
|
|
259
|
+
*
|
|
260
|
+
* This is useful for container secrets (e.g. Docker, Kubernetes) where
|
|
261
|
+
* sensitive values are mounted as files.
|
|
262
|
+
*
|
|
263
|
+
* @default false
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```env
|
|
267
|
+
* DATABASE_PASSWORD_FILE="/run/secrets/db_password"
|
|
268
|
+
* # resolves to DATABASE_PASSWORD=<contents of /run/secrets/db_password>
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
expandFileReferences?: boolean;
|
|
272
|
+
}
|
|
273
|
+
declare global {
|
|
274
|
+
var __c12_dotenv_vars__: Map<Record<string, any>, Set<string>>;
|
|
275
|
+
} //#endregion
|
|
276
|
+
//#region src/types.d.ts
|
|
277
|
+
interface ConfigLayerMeta {
|
|
278
|
+
name?: string;
|
|
279
|
+
[key: string]: any;
|
|
280
|
+
}
|
|
281
|
+
type UserInputConfig = Record<string, any>;
|
|
282
|
+
interface SourceOptions<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> {
|
|
283
|
+
/** Custom meta for layer */
|
|
284
|
+
meta?: MT;
|
|
285
|
+
/** Layer config overrides */
|
|
286
|
+
overrides?: T;
|
|
287
|
+
[key: string]: any;
|
|
288
|
+
/**
|
|
289
|
+
* Options for cloning remote sources
|
|
290
|
+
*
|
|
291
|
+
* @see https://giget.unjs.io
|
|
292
|
+
*/
|
|
293
|
+
giget?: DownloadTemplateOptions;
|
|
294
|
+
/**
|
|
295
|
+
* Install dependencies after cloning
|
|
296
|
+
*
|
|
297
|
+
* @see https://nypm.unjs.io
|
|
298
|
+
*/
|
|
299
|
+
install?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Token for cloning private sources
|
|
302
|
+
*
|
|
303
|
+
* @see https://giget.unjs.io#providing-token-for-private-repositories
|
|
304
|
+
*/
|
|
305
|
+
auth?: string;
|
|
306
|
+
}
|
|
307
|
+
interface ConfigLayer<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> {
|
|
308
|
+
config: T | null;
|
|
309
|
+
source?: string;
|
|
310
|
+
sourceOptions?: SourceOptions<T, MT>;
|
|
311
|
+
meta?: MT;
|
|
312
|
+
cwd?: string;
|
|
313
|
+
configFile?: string;
|
|
314
|
+
}
|
|
315
|
+
interface ResolvedConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> extends ConfigLayer<T, MT> {
|
|
316
|
+
config: T;
|
|
317
|
+
layers?: ConfigLayer<T, MT>[];
|
|
318
|
+
cwd?: string;
|
|
319
|
+
_configFile?: string;
|
|
320
|
+
}
|
|
321
|
+
type ConfigSource = "overrides" | "main" | "rc" | "packageJson" | "defaultConfig";
|
|
322
|
+
interface ConfigFunctionContext {
|
|
323
|
+
[key: string]: any;
|
|
324
|
+
}
|
|
325
|
+
interface ResolvableConfigContext<T extends UserInputConfig = UserInputConfig> {
|
|
326
|
+
configs: Record<ConfigSource, T | null | undefined>;
|
|
327
|
+
rawConfigs: Record<ConfigSource, ResolvableConfig<T> | null | undefined>;
|
|
328
|
+
}
|
|
329
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
330
|
+
type ResolvableConfig<T extends UserInputConfig = UserInputConfig> = MaybePromise<T | null | undefined> | ((ctx: ResolvableConfigContext<T>) => MaybePromise<T | null | undefined>);
|
|
331
|
+
interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> {
|
|
332
|
+
name?: string;
|
|
333
|
+
cwd?: string;
|
|
334
|
+
configFile?: string;
|
|
335
|
+
rcFile?: false | string;
|
|
336
|
+
globalRc?: boolean;
|
|
337
|
+
dotenv?: boolean | DotenvOptions;
|
|
338
|
+
envName?: string | false;
|
|
339
|
+
packageJson?: boolean | string | string[];
|
|
340
|
+
defaults?: T;
|
|
341
|
+
defaultConfig?: ResolvableConfig<T>;
|
|
342
|
+
overrides?: ResolvableConfig<T>;
|
|
343
|
+
omit$Keys?: boolean;
|
|
344
|
+
/** Context passed to config functions */
|
|
345
|
+
context?: ConfigFunctionContext;
|
|
346
|
+
resolve?: (id: string, options: LoadConfigOptions<T, MT>) => null | undefined | ResolvedConfig<T, MT> | Promise<ResolvedConfig<T, MT> | undefined | null>;
|
|
347
|
+
/** Custom import function used to load configuration files */
|
|
348
|
+
import?: (id: string) => Promise<unknown>;
|
|
349
|
+
/** Custom resolver for picking which export to use from the loaded module. Default: `(mod) => mod.default || mod` */
|
|
350
|
+
resolveModule?: (mod: any) => any;
|
|
351
|
+
giget?: false | DownloadTemplateOptions;
|
|
352
|
+
merger?: (...sources: Array<T | null | undefined>) => T;
|
|
353
|
+
extend?: false | {
|
|
354
|
+
extendKey?: string | string[];
|
|
355
|
+
};
|
|
356
|
+
configFileRequired?: boolean;
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
export { GitConfig as a, JitiOptions as i, LoadConfigOptions as n, ResolvedConfig as r, ConfigLayerMeta as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e}from"./vendor/common-BKG-EppI.mjs";export{e as parseYAML};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./common-ImpHew-F-C_Vy_bWl.mjs";export{e as parseYAML};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{r as e}from"./_chunks/
|
|
2
|
+
import{r as e}from"./_chunks/rolldown-runtime-coR7_hWt.mjs";import{D as t,E as n,O as r,_ as i,a,b as o,c as s,d as c,f as l,g as u,h as d,k as f,l as p,m,o as h,p as ee,s as te,u as ne,x as re,y as g}from"./_chunks/vendor/common-BKG-EppI.mjs";import{n as _}from"./_chunks/config-DlKQJJuJ.mjs";import{D as ie,E as v,M as ae,O as y,T as b,_ as x,b as S,c as C,d as oe,f as w,i as T,k as E,m as se,n as D,o as ce,p as le,r as O,s as k,t as ue,u as de,v as A,x as j,y as M}from"./_chunks/common-ImpHew-F-C_Vy_bWl.mjs";import{createRequire as fe}from"node:module";import{existsSync as pe,promises as N,readdirSync as me,statSync as he}from"node:fs";import{fileURLToPath as ge,pathToFileURL as P}from"node:url";import{mkdir as F,readFile as I,rm as _e,stat as ve,symlink as ye,writeFile as L}from"node:fs/promises";import{execSync as R,spawnSync as z}from"node:child_process";import{gzipSync as be}from"node:zlib";var B=u();async function xe(e=process.cwd(),t={}){let{force:n=!1,skipGitCheck:r=!1}=t;i.start(`Initializing basis configuration`);let a=(await d({cwd:e,name:`basis`}))._configFile;if(a&&!n)return i.error(`Configuration file already exists: ${a}`),i.info(`Use --force to overwrite.`),!1;let o=(await c(e))?.name||`npm`,s=o===`npm`?`npx`:o,l={git:{hooks:{"pre-commit":`${s} basis git staged`,"commit-msg":`${s} basis git lint-commit`},staged:{rules:{"**/*.{ts,tsx,js,jsx}":`basis lint`,"**/*.{json,md,yml,yaml}":`basis fmt`}}}},u=`import { defineBasisConfig } from "@funish/basis/config";
|
|
3
3
|
|
|
4
|
-
export default defineBasisConfig(${JSON.stringify(
|
|
5
|
-
`,
|
|
6
|
-
`).
|
|
7
|
-
`).
|
|
8
|
-
`)
|
|
9
|
-
|
|
10
|
-
`)[
|
|
11
|
-
`)[0];return h.length>a&&p.push(`Header too long (${h.length} chars). Max: ${a}`),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?(o.error(`Invalid commit message:`),p.forEach(e=>o.error(` ${e}`)),!1):(o.success(`Commit message validation passed`),!0)}async function R(t=process.cwd()){let{config:n}=await e(),r=n.git?.hooks;if(!r||Object.keys(r).length===0)return o.warn(`No Git hooks configured`),!0;let i=y(t,`.git/hooks`);try{for(let[e,t]of Object.entries(r))await l(y(i,e),`#!/bin/sh\n${t}\n`,{mode:493}),o.success(`Created ${e} hook`);return!0}catch(e){return o.error(`Failed to setup Git hooks:`,e),!1}}async function z(e=process.cwd()){return o.start(`Setting up Git configuration`),await R(e)?(o.success(`Git setup completed`),!0):!1}const B=t({meta:{name:`git`,description:`Git operations`},async run({rawArgs:e}){let t=e[0];if(!t){o.info(`Available subcommands: staged, lint-commit, setup`),o.info(`Git passthrough mode: basis git <git-command>`);return}switch(t){case`staged`:await P()||process.exit(1);return;case`lint-commit`:await L()||process.exit(1);return;case`setup`:await z()||process.exit(1);return;default:try{let t=await 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){o.error(`Git operation failed:`,e),process.exit(1)}}}}),V=t({meta:{name:`run`,description:`Run scripts or files`},async run({rawArgs:t}){t.length===0&&(o.error(`Please specify a script name or file path`),process.exit(1));let[n,...r]=t,i=process.cwd(),{config:a}=await e(),s=a.run?.config,c=y(i,n);if(C(c))try{let e=S(i,s),n=e.esmResolve(c);process.argv=[process.argv[0],n,...t.slice(1)],await e.import(n);return}catch(e){o.error(`Failed to run file:`),o.error(` ${String(e)}`),process.exit(1)}try{await v(n,{cwd:i,args:r})}catch(e){o.error(`Failed to run script "${n}":`),o.error(` ${String(e)}`),process.exit(1)}}});function H(e,t,n){if(t.version){if(w.valid(t.version))return t.version;throw Error(`Invalid version format: ${t.version}. Please use semantic versioning format (e.g., 1.0.0, 2.1.0-alpha.1)`)}if(!w.valid(e))throw Error(`Invalid current version format: ${e}. Please fix version in package.json to use semantic versioning format (e.g., 1.0.0)`);let r=w.prerelease(e),i=t.preid||(r&&typeof r[0]==`string`?r[0]:null)||n.preid||`edge`,a=`patch`;t.major?a=`major`:t.minor?a=`minor`:t.premajor?a=`premajor`:t.preminor?a=`preminor`:t.prepatch?a=`prepatch`:t.prerelease?a=r?`prerelease`:`prepatch`:t.fromGit&&(a=`patch`);let o=a===`prerelease`||a.startsWith(`pre`)?w.inc(e,a,i):w.inc(e,a);if(!o)throw Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return o}const U=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 r(c),u=l.version;if(!u)throw Error(`No version found in package.json`);let d=H(u,s,n.version||{});if(!s.allowSameVersion&&d===u)throw Error(`Version unchanged: ${u}. Use --allow-same-version to allow this.`);await a(await i(c),{...l,version:d}),o.success(`Version updated: ${u} → ${d}`)}catch(e){o.error(`Version update failed:`,e),process.exit(1)}}});async function W(e,t){let n=process.cwd(),i=await r(n),a=i.version,s=i.name;if(!s)throw Error(`Package name is required in package.json`);if(!a)throw Error(`Package version is required in package.json`);let c=(await h(n))?.name||`npm`,l={tag:`latest`,access:`public`,...t.npm},u=e.tag;if(!u&&a&&a.includes(`-`)){let e=a.match(/-(\w+)\.\d+$/);e&&(u=e[1])}u=u||l.tag||`latest`,b(`${c} publish ${(t=>{let n=[];e.tarball&&n.push(e.tarball),n.push(`--tag`,t);let r=e.access||l.access;return r&&n.push(`--access`,r),e.dryRun&&n.push(`--dry-run`),e.otp&&n.push(`--otp`,e.otp),n})(u).join(` `)}`,{stdio:`inherit`});let d=l.additionalTag;!e.dryRun&&d&&d!==u?b(`npm dist-tag add ${s}@${a} ${d}`,{cwd:n,stdio:`inherit`}):d&&o.info(`Skipping dist-tag ${d} (same as publish tag ${u})`)}async function G(e,t){let n=process.cwd(),r=t?.tagPrefix;if(!r)throw Error(`Git tagPrefix is required`);let i=`${r}${e}`,a=t?.message?t.message(e):`chore: release ${i}`;await 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 K=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 W({tag:t.tag,git:t.git,access:t.access||void 0,dryRun:t[`dry-run`],otp:t.otp},n.publish||{}),o.success(`Package published successfully`),t.git&&n.publish?.git){o.info(`Creating git tag and commit...`);let e=(await r(process.cwd())).version;e&&(await G(e,n.publish.git),o.success(`Git operations completed`))}}catch(e){o.error(`Publish failed:`,e),process.exit(1)}}}),q={npm:{outdated:[`outdated`],audit:[`audit`]},yarn:{outdated:[`outdated`,`-c`],audit:[`audit`]},pnpm:{outdated:[`outdated`],audit:[`audit`]},bun:{outdated:[`outdated`],audit:[`audit`]},deno:{outdated:null,audit:null}};async function J(t=process.cwd(),n,a=!1){let{config:s}=await e({overrides:n?{audit:{dependencies:n}}:void 0}),c=s.audit?.dependencies||{};o.start(`Auditing dependencies...`);let l=!1;if(c.blocked&&c.blocked.length>0)try{let e=await r(t),n={...e.dependencies,...e.devDependencies},i=Object.keys(n).filter(e=>c.blocked?.includes(e));i.length>0&&(o.error(`Found ${i.length} blocked package(s): ${i.join(`, `)}`),l=!0)}catch(e){o.error(`Failed to check blocked packages:`,e),l=!0}if(c.outdated)try{let e=(await h(t))?.name||`npm`,n=q[e];if(!n.outdated)o.info(`Skipping outdated check for ${e}`);else try{b(`${e} ${n.outdated.join(` `)}`,{cwd:t,stdio:`inherit`})}catch{o.warn(`Some dependencies are outdated`)}}catch(e){o.error(`Failed to check outdated dependencies:`,e),l=!0}if(c.security)try{let e=(await h(t))?.name||`npm`,n=q[e];if(!n.audit)o.info(`Skipping security audit for ${e}`);else try{b(`${e} ${n.audit.join(` `)}`,{cwd:t,stdio:`inherit`})}catch{l=!0}}catch(e){o.error(`Failed to check security vulnerabilities:`,e),l=!0}if(c.licenses&&(c.licenses.allowed||c.licenses.blocked))try{let e=await i(t),n=await Y(t),a=[];for(let t of n)try{let n=await r(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))){a.push(`${n.name}: ${e}`);continue}c.licenses.allowed&&c.licenses.allowed.length>0&&(c.licenses.allowed.some(t=>e.includes(t))||a.push(`${n.name}: ${e}`))}}catch{}a.length>0&&(o.error(`Packages with invalid licenses:`),a.forEach(e=>o.error(` ${e}`)),l=!0)}catch(e){o.error(`Failed to check licenses:`,e),l=!0}return l||o.success(`Dependencies audit passed`),!l}async function Y(e){try{return await T([`node_modules/*/package.json`,`node_modules/@*/*/package.json`,`node_modules/@*/*/*/package.json`],{cwd:e,absolute:!0})}catch{return[]}}async function X(t=process.cwd(),n){let{config:r}=await e({overrides:n?{audit:{structure:n}}:void 0}),i=r.audit?.structure||{};o.start(`Auditing project structure...`);let a=!1;if(i.required&&i.required.length>0){let e=[];for(let n of i.required)try{await c(y(t,n))}catch{n.includes(`*`)||n.includes(`?`)?(await T([n],{cwd:t})).length===0&&e.push(n):e.push(n)}e.length>0&&(o.error(`Missing required file(s)/director(ies): ${e.join(`, `)}`),a=!0)}if(i.files&&i.files.length>0)for(let e of i.files)try{let n=await T([e.pattern],{cwd:t}),r=new RegExp(e.rule),i=n.filter(e=>!r.test(e));i.length>0&&(o.error(`${e.message}: ${i.slice(0,5).join(`, `)}${i.length>5?`...`:``}`),a=!0)}catch(t){o.error(`Failed to check file naming rule: ${e.pattern}`,t),a=!0}if(i.dirs&&i.dirs.length>0)for(let e of i.dirs)try{let n=await T([e.pattern],{cwd:t}),r=new RegExp(e.rule),i=n.filter(e=>!r.test(e));i.length>0&&(o.error(`${e.message}: ${i.slice(0,5).join(`, `)}${i.length>5?`...`:``}`),a=!0)}catch(t){o.error(`Failed to check directory naming rule: ${e.pattern}`,t),a=!0}return a||o.success(`Structure audit passed`),!a}async function Z(t=process.cwd(),n=!1){let{config:r}=await e(),i=r.audit||{};o.start(`Running comprehensive project audit...`);let a=(await Promise.allSettled([J(t,i.dependencies,n),X(t,i.structure)])).filter(e=>e.status===`rejected`||e.status===`fulfilled`&&!e.value);return a.length===0?(o.success(`All audits passed`),!0):(o.error(`${a.length} audit(s) failed`),!1)}const Q=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 Z(t,e.fix);else{let r=[];e.dependencies&&r.push(()=>J(t,void 0,e.fix)),e.structure&&r.push(()=>X(t));for(let e of r)await e()||(n=!1)}n||(o.error(`Some audits failed`),process.exit(1))}}),te=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&&(o.error(`Please specify at least one package name`),o.info(`Example: basis add lodash`),process.exit(1));let n=t.filter(e=>!e.startsWith(`-`));n.length===0&&(o.error(`Please specify at least one package name`),process.exit(1));try{e.dev?(await m(n,{cwd:process.cwd()}),o.success(`Added ${n.join(`, `)} as dev dependencies`)):(await p(n,{cwd:process.cwd()}),o.success(`Added ${n.join(`, `)} as dependencies`))}catch(e){o.error(`Add packages failed:`,e),process.exit(1)}}}),ne=t({meta:{name:`remove`,description:`Remove dependencies`},async run({rawArgs:e}){e.length===0&&(o.error(`Please specify at least one package name`),o.info(`Example: basis remove lodash`),process.exit(1));let t=e.filter(e=>!e.startsWith(`-`));t.length===0&&(o.error(`Please specify at least one package name`),process.exit(1));try{await _(t,{cwd:process.cwd()}),o.success(`Removed ${t.join(`, `)}`)}catch(e){o.error(`Remove packages failed:`,e),process.exit(1)}}}),re=t({meta:{name:`dlx`,description:`Execute package without installation`},async run({rawArgs:e}){try{e.length===0&&(o.error(`Please specify a package to run`),process.exit(1));let[t,...n]=e;await g(t,{args:n,cwd:process.cwd()}),o.success(`Dlx completed`)}catch(e){o.error(`Dlx failed:`,e),process.exit(1)}}}),$=await r(import.meta.url);n(t({meta:{name:`basis`,description:$.description,version:$.version},subCommands:{init:D,lint:O,fmt:k,check:A,build:j,git:B,run:V,version:U,publish:K,audit:Q,add:te,remove:ne,dlx:re}}));export{};
|
|
4
|
+
export default defineBasisConfig(${JSON.stringify(l,null,2)});
|
|
5
|
+
`,f=`${e}/basis.config.ts`;if(await L(f,u,`utf8`),i.success(`Configuration created in ${f}`),!r)try{await(0,B.exec)([`--version`],e),i.info(`Git detected`)}catch{i.info(`Git not found`)}return i.success(`Basis initialization completed!`),i.info(`Run 'basis git setup' to setup Git hooks`),!0}const Se=r({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 xe(process.cwd(),{force:e.force,skipGitCheck:e[`skip-git-check`],skipInstall:e[`skip-install`]})}catch(e){i.error(`Init failed:`,e),process.exit(1)}}});function V(e){let{pkg:r,bin:a,args:o}=e,s=t(n(fe(import.meta.url).resolve(r)),a),c=z(process.execPath,[s,...o],{stdio:`inherit`,shell:!1});return c.error&&i.error(c.error),c.status!==0&&i.error(`${r} failed with exit code ${c.status}`),c}const Ce=r({meta:{name:`lint`,description:`Lint code`},async run({rawArgs:e}){let{config:t}=await _(),n=t.lint?.config||[];V({pkg:`oxlint`,bin:`cli.js`,args:e.length>0?e:n}).status!==0&&process.exit(1),i.success(`Linting completed`)}}),we=r({meta:{name:`fmt`,description:`Format code`},async run({rawArgs:e}){let{config:t}=await _(),n=t.fmt?.config||[];V({pkg:`oxfmt`,bin:`cli.js`,args:e.length>0?e:n}).status!==0&&process.exit(1),i.success(`Formatting completed`)}});function H(e){return v(e).replace(process.cwd(),`.`)}function U(e){if(Array.isArray(e)){let t=0,n=0;for(let r of e){let{size:e,files:i}=U(r);t+=e,n+=i}return{size:t,files:n}}let t=0,n=me(e,{withFileTypes:!0,recursive:!0});for(let e of n){let n=A(e.parentPath,e.name);if(e.isFile()){let{size:e}=he(n);t+=e}}return{size:t,files:n.length}}async function Te(e,t){let{output:n}=await(await E({input:A(e,t),plugins:[],platform:`neutral`,logLevel:`silent`,external:t=>t[0]!==`.`&&!t.startsWith(e)})).generate({codeSplitting:!1}),r=n[0].code,{code:i}=M(t,r);return{size:Buffer.byteLength(r),minSize:Buffer.byteLength(i),minGzipSize:be(i).length}}async function Ee(e,t){let{output:n}=await(await E({input:`#entry`,platform:`neutral`,external:t=>t[0]!==`.`&&!t.startsWith(e),logLevel:`silent`,plugins:[{name:`virtual-entry`,async resolveId(e,t,n){if(e===`#entry`)return{id:e};let r=await this.resolve(e,t,n);return r?(r.moduleSideEffects=null,r):null},load(n){if(n===`#entry`)return`import * as _lib from "${A(e,t)}";`}}]})).generate({codeSplitting:!1});return process.env.INSPECT_BUILD&&(console.log(`---------[side effects]---------`),console.log(t),console.log(n[0].code),console.log(`-------------------------------`)),Buffer.byteLength(n[0].code.trim())}const W=/^#![^\n]*/;function De(){return{name:`isbuild-shebang`,async writeBundle(e,t){for(let[n,r]of Object.entries(t))r.type===`chunk`&&Oe(r.code)&&await G(v(e.dir,n))}}}function Oe(e){return W.test(e)}async function G(e){await N.chmod(e,493).catch(()=>{})}async function ke(e,t,n){let r=Ae(t.input,e);if(t.stub){for(let[t,n]of Object.entries(r)){let r=A(e.pkgDir,`dist`,`${t}.mjs`);await F(C(r),{recursive:!0}),T.log(`${O.magenta(`[bundle] `)} ${O.underline(H(r))} ${O.dim(`(stub)`)}`);let i=await I(n,`utf8`),a=S(n,i).module.staticExports.flatMap(e=>e.entries.map(e=>e.exportName.kind===`Default`?`default`:e.exportName.name)).includes(`default`),o=i.split(`
|
|
6
|
+
`)[0],s=o.startsWith(`#!`),c=b(C(r),n);await L(r,`${s?o+`
|
|
7
|
+
`:``}export * from "${c}";\n${a?`export { default } from "${c}";\n`:``}`,`utf8`),s&&await G(r),await L(r.replace(/\.mjs$/,`.d.mts`),`export * from "${c}";\n${a?`export { default } from "${c}";\n`:``}`,`utf8`)}return}let i=[...Object.keys(e.pkg.dependencies||{}),...Object.keys(e.pkg.peerDependencies||{})].map(e=>RegExp(`^${e}`)),a=k(t.rolldown,{cwd:e.pkgDir,input:r,plugins:[De(),oe({rootDir:e.pkgDir,conditions:[`node`,`import`,`default`],include:i,trace:!1})],platform:`node`,onLog(e,t,n){t.code!==`EVAL`&&n(e,t)},resolve:{mainFields:[`module`,`main`]},treeshake:{moduleSideEffects:`no-external`}});t.dts!==!1&&a.plugins.push(...de(k(t.dts,{eager:!0}))),await n.rolldownConfig?.(a,e);let o=await E(a),s=v(e.pkgDir,t.outDir||`dist`),c={dir:s,format:`esm`,entryFileNames:`[name].mjs`,chunkFileNames:`_chunks/[name]-[hash].mjs`,minify:t.minify??`dce-only`,codeSplitting:{groups:[{test:/node_modules/,name:e=>{let t=e.match(/.*\/node_modules\/(?<package>@[^/]+\/[^/]+|[^/]+)/)?.groups?.package,n=/\.d\.[mc]?ts$/.test(e);return`vendor/${t||`common`}${n?`.d`:``}`}}]}};await n.rolldownOutput?.(c,o,e);let{output:l}=await o.write(c);await o.close();let u=[],d=new Map,f=e=>{let t=d.get(e);if(t)return[...t].sort();t=new Set,d.set(e,t);for(let n of e.imports){let e=l.find(e=>e.type===`chunk`&&e.fileName===n);if(e){for(let n of f(e))t.add(n);continue}t.add(n)}return[...t].sort()};for(let e of l)e.type!==`chunk`||!e.isEntry||e.fileName.endsWith(`ts`)||u.push({name:e.fileName,exports:e.exports,deps:f(e),...await Te(s,e.fileName),sideEffectSize:await Ee(s,e.fileName)});T.log(`\n${u.map(e=>[O.magenta(`[bundle] `)+`${O.underline(H(A(s,e.name)))}`,O.dim(`${O.bold(`Size:`)} ${j(e.size)}, ${O.bold(j(e.minSize))} minified, ${j(e.minGzipSize)} min+gzipped (Side effects: ${j(e.sideEffectSize)})`),e.exports.some(e=>e!==`default`)?O.dim(`${O.bold(`Exports:`)} ${e.exports.map(e=>e).join(`, `)}`):``,e.deps.length>0?O.dim(`${O.bold(`Dependencies:`)} ${e.deps.join(`, `)}`):``].filter(Boolean).join(`
|
|
8
|
+
`)).join(`
|
|
9
|
+
|
|
10
|
+
`)}`)}function Ae(e,t){let n={};for(let r of Array.isArray(e)?e:[e]){r=y(r,{from:t.pkgDir,extensions:[`.ts`,`.js`,`.mjs`,`.cjs`,`.json`]});let e=b(A(t.pkgDir,`src`),r);if(e.startsWith(`..`)&&(e=b(A(t.pkgDir),r)),e.startsWith(`..`))throw Error(`Source should be within the package directory (${t.pkgDir}): ${r}`);let i=A(C(e),D(e,w(e)));if(n[i])throw Error(`Rename one of the entries to avoid a conflict in the dist name "${i}":\n - ${r}\n - ${n[i]}`);n[i]=r}return n}const je=[`.js`,`.mjs`,`.cjs`,`.ts`,`.mts`,`.cts`];function K(e){let t={};e.pkg.name&&(t[e.pkg.name]=e.pkgDir);let n=e.pkg;if(n.exports){for(let[r,i]of Object.entries(n.exports))if(r.startsWith(`./`)&&i&&typeof i==`object`&&`import`in i&&i.import){let n=i.import.replace(/^\.\//,``).replace(/^dist\//,`src/`).replace(/\.m?js$/,``);t[r]=v(e.pkgDir,n)}}return t}function Me(e){let t=e.match(/^#![^\n]*/);return t?t[0]:``}async function Ne(e,t,n){let r=n||{jiti:{transformOptions:{babel:{plugins:[]}},alias:{}}},i=ce(e.pkgDir,{...r.jiti,alias:k(K(e),r.jiti.alias),transformOptions:{...r.jiti.transformOptions}}),a=r.jiti.transformOptions?.babel?.plugins,o=[],s=JSON.stringify(k(r.jiti,{alias:k(K(e),r.jiti.alias),transformOptions:k(r.jiti.transformOptions||{},{babel:{...r.jiti.transformOptions?.babel,plugins:`__$BABEL_PLUGINS`}})}),null,2).replace(`"__$BABEL_PLUGINS"`,Array.isArray(a)?`[`+a.map((e,t)=>{if(Array.isArray(e)){let[n,...r]=e;return o.push(n),`[`+[`plugin${t}`,...r.map(e=>JSON.stringify(e))].join(`, `)+`]`}else return o.push(e),`plugin${t}`}).join(`,`)+`]`:`[]`),c=await Pe(t.input,e);for(let[n,r]of Object.entries(c)){let a=v(e.pkgDir,t.outDir||`dist`,`${n}.mjs`),c=e.pkg.type===`module`,l=le(i.esmResolve(r)),u=l.slice(0,Math.max(0,l.length-w(l).length)),d=c?`${l.replace(/(\.m?)(ts)$/,`$1js`)}`:u,f=Me(await N.readFile(l,`utf8`));await F(C(a),{recursive:!0}),T.log(`${O.magenta(`[stub] `)} ${O.underline(a)} ${O.dim(`(jiti)`)}`);let p=await ie(l,{extensions:je}).catch(e=>(T.warn(`Cannot analyze ${l} for exports:`,e.message),[])),m=p.includes(`default`)||p.length===0;await L(a,(f?f+`
|
|
11
|
+
`:``)+[`import { createJiti } from ${JSON.stringify(`jiti`)};`,...o.map((e,t)=>`import plugin${t} from ${JSON.stringify(e)}`),``,`const jiti = createJiti(import.meta.url, ${s})`,``,`/** @type {import(${JSON.stringify(d)})} */`,`const _module = await jiti.import(${JSON.stringify(l)});`,m?`
|
|
12
|
+
export default _module?.default ?? _module;`:``,...p.filter(e=>e!==`default`).map(e=>`export const ${e} = _module.${e};`)].join(`
|
|
13
|
+
`));let h=[`export * from ${JSON.stringify(d)};`,m?`export { default } from ${JSON.stringify(d)};`:``].join(`
|
|
14
|
+
`);await L(a.replace(/\.mjs$/,`.d.mts`),h),f&&await G(a)}}async function Pe(e,t){let n={};for(let r of Array.isArray(e)?e:[e]){let e=r,i=b(A(t.pkgDir,`src`),e);if(i.startsWith(`..`)&&(i=b(A(t.pkgDir),e)),i.startsWith(`..`))throw Error(`Source should be within the package directory (${t.pkgDir}): ${r}`);let a=A(C(i),D(i,w(i)));if(n[a])throw Error(`Rename one of the entries to avoid a conflict in the dist name "${a}":\n - ${r}\n - ${n[a]}`);n[a]=e}return n}async function Fe(e,t){let n=[];for(let e of await se(`**/*.*`,{cwd:t.input}))t.filter&&await t.filter(e)===!1||n.push((async()=>{let n=A(t.input,e);switch(w(n)){case`.ts`:{let r=A(t.outDir,e.replace(/\.ts$/,`.mjs`)),i=await Le(n,t,r);return await F(C(r),{recursive:!0}),await L(r,i.code,`utf8`),W.test(i.code)&&await G(r),i.declaration&&await L(r.replace(/\.mjs$/,`.d.mts`),i.declaration,`utf8`),r}default:{let r=A(t.outDir,e);if(await F(C(r),{recursive:!0}),t.stub)await ye(n,r,`junction`).catch(()=>{});else{let e=await I(n,`utf8`);await L(r,e,`utf8`),W.test(e)&&await G(r)}return r}}})());let r=await Promise.allSettled(n),i=r.filter(e=>e.status===`rejected`).map(e=>e.reason);if(i.length>0){let e=[],n=[];for(let t of i.flatMap(e=>Array.isArray(e.cause)?e.cause:[e]))t.message?.includes(`--isolatedDeclarations`)?e.push(t):n.push(t);for(let e of n)T.error(e);for(let t of e)T.warn(t);if(n.length>0)throw Error(`Errors while transforming ${t.input}`)}let a=r.filter(e=>e.status===`fulfilled`).map(e=>e.value);T.log(`\n${O.magenta(`[transform] `)}${O.underline(H(t.outDir)+`/`)}${t.stub?O.dim(` (stub)`):``}\n${O.dim(Ie(a.map(e=>H(e))))}`)}function Ie(e,t=process.stdout.columns||80){if(e.length===0)return``;let n=Math.max(...e.map(e=>e.length))+2,r=Math.max(1,Math.floor(t/n)),i=[];for(let t=0;t<e.length;t+=r){let a=e.slice(t,t+r);i.push(a.map(e=>e.padEnd(n)).join(``))}return i.join(`
|
|
15
|
+
`)}async function Le(e,t,n){let r=await I(e,`utf8`),i={lang:`ts`,sourceType:`module`},a=S(e,r,{...i});if(t.stub){let t=a?.module?.staticExports?.find(e=>e.entries.some(e=>e.exportName.kind===`Default`))!==void 0,r=b(C(n),e),i=`export * from "${r}";${t?`\nexport { default } from "${r}";`:``}`;return{code:i,declaration:i}}if(a.errors.length>0)throw Error(`Errors while parsing ${e}:`,{cause:a.errors});let o={...t.resolve,from:P(e),extensions:t.resolve?.extensions??[`.ts`,`.js`,`.mjs`,`.cjs`,`.json`],suffixes:t.resolve?.suffixes??[``,`/index`]},s=new ue(r),c=new Set,l=t=>{let n=t.value;if(!n.startsWith(`.`)||c.has(t.start))return;c.add(t.start);let r=y(n,o),i=b(C(e),r.replace(/\.ts$/,`.mjs`));s.remove(t.start,t.end),s.prependLeft(t.start,JSON.stringify(i.startsWith(`.`)?i:`./${i}`))};for(let e of a.module.staticImports)l(e.moduleRequest);for(let e of a.module.staticExports)for(let t of e.entries)t.moduleRequest&&l(t.moduleRequest);r=s.toString();let u=t.dts??!0;typeof u==`function`&&(u=await u(e));let d=ae(e,r,{...k(t.oxc,i),cwd:C(e),typescript:k(t.oxc?.typescript||{},u?{declaration:{stripInternal:!0}}:{})});if(d.warnings.length>0)for(let e of d.warnings)T.warn(e);if(d.errors.length>0)throw d.errors.length===1?d.errors[0]:Error(`Errors while transforming ${e}`,{cause:d.errors});if(t.minify){let n=M(e,d.code,t.minify===!0?{}:t.minify);d.code=n.code,d.map=n.map}return d}async function Re(e){let t=Date.now(),n=q(e.cwd),r={pkg:await ze(A(n,`package.json`)).catch(()=>({})),pkgDir:n};T.log(`📦 Building \`${r.pkg.name||`<no name>`}\` (\`${r.pkgDir}\`)`);let i=e.hooks||{};await i.start?.(r);let a=(e.entries||[]).map(e=>{let t;if(typeof e==`string`){let[n,r]=e.split(`:`);t=n.endsWith(`/`)?{type:`transform`,input:n,outDir:r}:{type:`bundle`,input:n.split(`,`),outDir:r}}else t=e;if(!t.input)throw Error(`Build entry missing \`input\`: ${JSON.stringify(t,null,2)}`);return t={...t},t.outDir=q(t.outDir||`dist`,n),t.input=Array.isArray(t.input)?t.input.map(e=>q(e,n)):q(t.input,n),t});await i.entries?.(a,r);let o=[],s=a.map(e=>e.outDir).filter(Boolean);for(let e of s.sort((e,t)=>e.localeCompare(t)))o.some(t=>e.startsWith(t))||o.push(e);for(let e of o)T.log(`🧻 Cleaning up \`${H(e)}\``),await _e(e,{recursive:!0,force:!0});for(let e of a)e.type===`bundle`?e.stub?await Ne(r,e):await ke(r,e,i):await Fe(r,e);if(await i.end?.(r),!a.every(e=>e.stub)){let e=U(o);T.log(O.dim(`\nΣ Total dist byte size: ${O.underline(j(e.size))} (${O.underline(e.files)} files)`))}T.log(`\n✅ isbuild finished in ${Date.now()-t}ms`)}function q(e,t){return typeof e==`string`&&x(e)?e:e instanceof URL?ge(e):v(t||`.`,e||`.`)}function ze(e){return import(x(e)?P(e).href:e,{with:{type:`json`}}).then(e=>e.default)}const Be=r({meta:{name:`build`,description:`Build project`},args:{dir:{type:`string`,description:`Project directory`,default:`.`},stub:{type:`boolean`,description:`Generate stub files`,default:!1}},async run({args:e}){let n=t(e.dir||`.`);try{let{config:t={}}=await d({name:`isbuild`,configFile:`build.config`,cwd:n}),r=(t.entries||[]).map(t=>{if(typeof t==`string`){let[n,r]=t.split(`:`);return n.endsWith(`/`)?{type:`transform`,input:n,outDir:r,stub:e.stub}:{type:`bundle`,input:n.split(`,`),outDir:r,stub:e.stub}}return{...t,stub:e.stub}});(!r||r.length===0)&&(i.error(`No build entries specified in build.config.`),process.exit(1)),await Re({cwd:n,...t,entries:r}),i.success(`Build completed`)}catch(e){i.error(`Build failed:`,e),process.exit(1)}}});var Ve=e(s());async function He(){try{let e=R(`git --exec-path`,{encoding:`utf8`}).trim();if(e){let n=(0,B.setupEnvironment)({LOCAL_GIT_DIRECTORY:t(e,`..`,`..`,`..`)});Object.assign(process.env,n.env),i.debug(`Using system Git from: ${n.gitLocation}`)}}catch{i.debug(`System Git not found, dugite will use embedded Git`)}}He();async function Ue(e){try{let t=(await(0,B.exec)([`diff`,`--cached`,`--name-only`],e)).stdout.trim().split(`
|
|
16
|
+
`).filter(Boolean),n=await(0,B.exec)([`diff`,`--cached`,`--name-only`,`--diff-filter=D`],e),r=new Set(n.stdout.trim().split(`
|
|
17
|
+
`).filter(Boolean));return t.filter(e=>!r.has(e))}catch{return[]}}async function We(e=process.cwd()){let{config:t}=await _(),n=t.git?.staged?.rules||{};if(Object.keys(n).length===0)return i.warn(`No staged rules configured. Add git.staged.rules to your basis.config.ts`),!0;let r=await Ue(e);if(r.length===0)return i.info(`No staged files to check`),!0;i.start(`Checking ${r.length} staged file(s)`);let a=!1,o=new Set;for(let[t,s]of Object.entries(n)){let n=(0,Ve.default)(t),c=r.filter(e=>!o.has(e)&&n(e));if(c.length!==0){i.info(`Running ${s} for ${c.length} file(s) matching ${t}`);try{let t=await(0,B.exec)([`status`,`--porcelain`],e),n=new Set;t.stdout.trim().split(`
|
|
18
|
+
`).filter(Boolean).forEach(e=>{let t=e.match(/^(..)\s+(.+)$/);if(!t)return;let[,r,i]=t;(r[1]===`M`||r===` M`)&&n.add(i)}),R(s,{cwd:e,stdio:`inherit`});let r=await(0,B.exec)([`status`,`--porcelain`],e),a=new Set;r.stdout.trim().split(`
|
|
19
|
+
`).filter(Boolean).forEach(e=>{let t=e.match(/^(..)\s+(.+)$/);if(!t)return;let[,r,i]=t;(r[1]===`M`||r===` M`)&&(c.includes(i)?a.add(i):n.has(i)||a.add(i))}),a.size>0&&(await(0,B.exec)([`add`,...Array.from(a)],e),i.info(`Re-staged ${a.size} file(s) after formatting`)),c.forEach(e=>o.add(e))}catch(e){a=!0,i.error(`Staged check failed for pattern '${t}':`,e)}}}return a?(i.error(`Some staged files checks failed`),!1):(i.success(`Staged files check passed`),!0)}const Ge=[`feat`,`fix`,`docs`,`style`,`refactor`,`perf`,`test`,`build`,`ci`,`chore`,`revert`];function Ke(e){let t=e.trim().split(`
|
|
20
|
+
`)[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 qe(e=process.cwd()){let{config:n}=await _(),r=n.git?.commitMsg,a=r?.types||Ge,o=r?.maxLength||72,s=r?.minLength||10,c=r?.scopeRequired||!1,l=r?.allowedScopes||[],u;try{let n=t(e,`.git/COMMIT_EDITMSG`);try{u=(await I(n)).toString(`utf8`)}catch{u=(await(0,B.exec)([`log`,`-1`,`--pretty=%B`],e)).stdout.trim()}}catch(e){return i.error(`Failed to read commit message:`,e),!1}let d=[],f=Ke(u);if(!f)return i.error(`Invalid commit format. Expected: type(scope): subject`),!1;a.includes(f.type)||d.push(`Invalid type '${f.type}'. Allowed: ${a.join(`, `)}`);let p=u.split(`
|
|
21
|
+
`)[0];return p.length>o&&d.push(`Header too long (${p.length} chars). Max: ${o}`),p.length<s&&d.push(`Header too short (${p.length} chars). Min: ${s}`),c&&!f.scope&&d.push(`Scope is required`),f.scope&&l.length>0&&!l.includes(f.scope)&&d.push(`Invalid scope '${f.scope}'. Allowed: ${l.join(`, `)}`),d.length>0?(i.error(`Invalid commit message:`),d.forEach(e=>i.error(` ${e}`)),!1):(i.success(`Commit message validation passed`),!0)}async function Je(e=process.cwd()){let{config:n}=await _(),r=n.git?.hooks;if(!r||Object.keys(r).length===0)return i.warn(`No Git hooks configured`),!0;let a=t(e,`.git/hooks`);try{for(let[e,n]of Object.entries(r))await L(t(a,e),`#!/bin/sh\n${n}\n`,{mode:493}),i.success(`Created ${e} hook`);return!0}catch(e){return i.error(`Failed to setup Git hooks:`,e),!1}}async function Ye(e=process.cwd()){return i.start(`Setting up Git configuration`),await Je(e)?(i.success(`Git setup completed`),!0):!1}const Xe=r({meta:{name:`git`,description:`Git operations`},async run({rawArgs:e}){let t=e[0];if(!t){i.info(`Available subcommands: staged, lint-commit, setup`),i.info(`Git passthrough mode: basis git <git-command>`);return}switch(t){case`staged`:await We()||process.exit(1);return;case`lint-commit`:await qe()||process.exit(1);return;case`setup`:await Ye()||process.exit(1);return;default:try{let t=await(0,B.exec)(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){i.error(`Git operation failed:`,e),process.exit(1)}}}}),Ze=r({meta:{name:`run`,description:`Run scripts or files`},async run({rawArgs:e}){e.length===0&&(i.error(`Please specify a script name or file path`),process.exit(1));let[n,...r]=e,a=process.cwd(),{config:o}=await _(),s=o.run?.config,c=t(a,n);if(pe(c))try{let t=te(a,s),n=t.esmResolve(c);process.argv=[process.argv[0],n,...e.slice(1)],await t.import(n);return}catch(e){i.error(`Failed to run file:`),i.error(` ${String(e)}`),process.exit(1)}try{await m(n,{cwd:a,args:r})}catch(e){i.error(`Failed to run script "${n}":`),i.error(` ${String(e)}`),process.exit(1)}}});var J=e(h());function Qe(e,t,n){if(t.version){if(J.default.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(!J.default.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=J.default.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`)?J.default.inc(e,a,i):J.default.inc(e,a);if(!o)throw Error(`Failed to calculate new version from ${e}. Please check your version increment options.`);return o}const Y=r({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:t}=await _(),n={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)?n[t]=!0:n.version=t}let r=process.cwd(),a=await g(r),s=a.version;if(!s)throw Error(`No version found in package.json`);let c=Qe(s,n,t.version||{});if(!n.allowSameVersion&&c===s)throw Error(`Version unchanged: ${s}. Use --allow-same-version to allow this.`);await re(await o(r),{...a,version:c}),i.success(`Version updated: ${s} → ${c}`)}catch(e){i.error(`Version update failed:`,e),process.exit(1)}}});async function $e(e,t){let n=process.cwd(),r=await g(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 c(n))?.name||`npm`,l={tag:`latest`,access:`public`,...t.npm},u=e.tag;if(!u&&a&&a.includes(`-`)){let e=a.match(/-(\w+)\.\d+$/);e&&(u=e[1])}u=u||l.tag||`latest`;let d=z(s,[`publish`,...(t=>{let n=[];e.tarball&&n.push(e.tarball),n.push(`--tag`,t);let r=e.access||l.access;return r&&n.push(`--access`,r),e.dryRun&&n.push(`--dry-run`),e.otp&&n.push(`--otp`,e.otp),n})(u)],{stdio:`inherit`,shell:!0});if(d.status!==0){i.error(`Publish failed with exit code ${d.status}`);return}let f=l.additionalTag;if(!e.dryRun&&f&&f!==u){let e=z(`npm`,[`dist-tag`,`add`,`${o}@${a}`,f],{cwd:n,stdio:`inherit`,shell:!0});if(e.status!==0){i.error(`Failed to add dist-tag with exit code ${e.status}`);return}}else f&&i.info(`Skipping dist-tag ${f} (same as publish tag ${u})`)}async function et(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(0,B.exec)([`add`,`package.json`],n),await(0,B.exec)([`commit`,`-m`,a],n),await(0,B.exec)([`tag`,i,...t?.signTag?[`--sign`]:[]],n),t?.push&&(await(0,B.exec)([`push`],n),await(0,B.exec)([`push`,`--tags`],n))}const tt=r({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:t}=await _();if(await $e({tag:e.tag,git:e.git,access:e.access||void 0,dryRun:e[`dry-run`],otp:e.otp},t.publish||{}),i.success(`Package published successfully`),e.git&&t.publish?.git){i.info(`Creating git tag and commit...`);let e=(await g(process.cwd())).version;e&&(await et(e,t.publish.git),i.success(`Git operations completed`))}}catch(e){i.error(`Publish failed:`,e),process.exit(1)}}}),X={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 Z(e=process.cwd(),t,n=!1){let{config:r}=await _({overrides:t?{audit:{dependencies:t}}:void 0}),a=r.audit?.dependencies||{};i.start(`Auditing dependencies...`);let s=!1;if(a.blocked&&a.blocked.length>0)try{let t=await g(e),n={...t.dependencies,...t.devDependencies},r=Object.keys(n).filter(e=>a.blocked?.includes(e));r.length>0&&(i.error(`Found ${r.length} blocked package(s): ${r.join(`, `)}`),s=!0)}catch(e){i.error(`Failed to check blocked packages:`,e),s=!0}if(a.outdated)try{let t=(await c(e))?.name||`npm`,n=X[t];n.outdated?z(t,n.outdated,{cwd:e,stdio:`inherit`,shell:!0}).status!==0&&i.warn(`Some dependencies are outdated`):i.info(`Skipping outdated check for ${t}`)}catch(e){i.error(`Failed to check outdated dependencies:`,e),s=!0}if(a.security)try{let t=(await c(e))?.name||`npm`,n=X[t];n.audit?z(t,n.audit,{cwd:e,stdio:`inherit`,shell:!0}).status!==0&&(s=!0):i.info(`Skipping security audit for ${t}`)}catch(e){i.error(`Failed to check security vulnerabilities:`,e),s=!0}if(a.licenses&&(a.licenses.allowed||a.licenses.blocked))try{let t=await o(e),n=await nt(e),r=[];for(let e of n)try{let n=await g(e);if(!n.name||e===t)continue;if(n.license){let e=Array.isArray(n.license)?n.license.join(`, `):n.license;if(a.licenses.blocked&&a.licenses.blocked.some(t=>e.includes(t))){r.push(`${n.name}: ${e}`);continue}a.licenses.allowed&&a.licenses.allowed.length>0&&(a.licenses.allowed.some(t=>e.includes(t))||r.push(`${n.name}: ${e}`))}}catch{}r.length>0&&(i.error(`Packages with invalid licenses:`),r.forEach(e=>i.error(` ${e}`)),s=!0)}catch(e){i.error(`Failed to check licenses:`,e),s=!0}return s||i.success(`Dependencies audit passed`),!s}async function nt(e){try{return await a([`node_modules/*/package.json`,`node_modules/@*/*/package.json`,`node_modules/@*/*/*/package.json`],{cwd:e,absolute:!0})}catch{return[]}}async function Q(e=process.cwd(),n){let{config:r}=await _({overrides:n?{audit:{structure:n}}:void 0}),o=r.audit?.structure||{};i.start(`Auditing project structure...`);let s=!1;if(o.required&&o.required.length>0){let n=[];for(let r of o.required)try{await ve(t(e,r))}catch{r.includes(`*`)||r.includes(`?`)?(await a([r],{cwd:e})).length===0&&n.push(r):n.push(r)}n.length>0&&(i.error(`Missing required file(s)/director(ies): ${n.join(`, `)}`),s=!0)}if(o.files&&o.files.length>0)for(let t of o.files)try{let n=await a([t.pattern],{cwd:e}),r=new RegExp(t.rule),o=n.filter(e=>!r.test(e));o.length>0&&(i.error(`${t.message}: ${o.slice(0,5).join(`, `)}${o.length>5?`...`:``}`),s=!0)}catch(e){i.error(`Failed to check file naming rule: ${t.pattern}`,e),s=!0}if(o.dirs&&o.dirs.length>0)for(let t of o.dirs)try{let n=await a([t.pattern],{cwd:e}),r=new RegExp(t.rule),o=n.filter(e=>!r.test(e));o.length>0&&(i.error(`${t.message}: ${o.slice(0,5).join(`, `)}${o.length>5?`...`:``}`),s=!0)}catch(e){i.error(`Failed to check directory naming rule: ${t.pattern}`,e),s=!0}return s||i.success(`Structure audit passed`),!s}async function rt(e=process.cwd(),t=!1){let{config:n}=await _(),r=n.audit||{};i.start(`Running comprehensive project audit...`);let a=(await Promise.allSettled([Z(e,r.dependencies,t),Q(e,r.structure)])).filter(e=>e.status===`rejected`||e.status===`fulfilled`&&!e.value);return a.length===0?(i.success(`All audits passed`),!0):(i.error(`${a.length} audit(s) failed`),!1)}const it=r({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 rt(t,e.fix);else{let r=[];e.dependencies&&r.push(()=>Z(t,void 0,e.fix)),e.structure&&r.push(()=>Q(t));for(let e of r)await e()||(n=!1)}n||(i.error(`Some audits failed`),process.exit(1))}}),at=r({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&&(i.error(`Please specify at least one package name`),i.info(`Example: basis add lodash`),process.exit(1));let n=t.filter(e=>!e.startsWith(`-`));n.length===0&&(i.error(`Please specify at least one package name`),process.exit(1));try{e.dev?(await ne(n,{cwd:process.cwd()}),i.success(`Added ${n.join(`, `)} as dev dependencies`)):(await p(n,{cwd:process.cwd()}),i.success(`Added ${n.join(`, `)} as dependencies`))}catch(e){i.error(`Add packages failed:`,e),process.exit(1)}}}),ot=r({meta:{name:`remove`,description:`Remove dependencies`},async run({rawArgs:e}){e.length===0&&(i.error(`Please specify at least one package name`),i.info(`Example: basis remove lodash`),process.exit(1));let t=e.filter(e=>!e.startsWith(`-`));t.length===0&&(i.error(`Please specify at least one package name`),process.exit(1));try{await ee(t,{cwd:process.cwd()}),i.success(`Removed ${t.join(`, `)}`)}catch(e){i.error(`Remove packages failed:`,e),process.exit(1)}}}),st=r({meta:{name:`dlx`,description:`Execute package without installation`},async run({rawArgs:e}){try{e.length===0&&(i.error(`Please specify a package to run`),process.exit(1));let[t,...n]=e;await l(t,{args:n,cwd:process.cwd()}),i.success(`Dlx completed`)}catch(e){i.error(`Dlx failed:`,e),process.exit(1)}}}),$=await g(import.meta.url);f(r({meta:{name:`basis`,description:$.description,version:$.version},subCommands:{init:Se,lint:Ce,fmt:we,build:Be,git:Xe,run:Ze,version:Y,publish:tt,audit:it,add:at,remove:ot,dlx:st}}));export{};
|
package/dist/commands/fmt.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineCommand as e}from"citty";import{consola as t}from"consola";import{
|
|
1
|
+
import{defineCommand as e}from"citty";import{consola as t}from"consola";import{loadConfig as n}from"../config.mjs";import{runTool as r}from"../modules/run.mjs";export const fmtCommand=e({meta:{name:`fmt`,description:`Format code`},async run({rawArgs:e}){let{config:i}=await n(),a=i.fmt?.config||[];r({pkg:`oxfmt`,bin:`cli.js`,args:e.length>0?e:a}).status!==0&&process.exit(1),t.success(`Formatting completed`)}});
|
package/dist/commands/lint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineCommand as e}from"citty";import{consola as t}from"consola";import{
|
|
1
|
+
import{defineCommand as e}from"citty";import{consola as t}from"consola";import{loadConfig as n}from"../config.mjs";import{runTool as r}from"../modules/run.mjs";export const lintCommand=e({meta:{name:`lint`,description:`Lint code`},async run({rawArgs:e}){let{config:i}=await n(),a=i.lint?.config||[];r({pkg:`oxlint`,bin:`cli.js`,args:e.length>0?e:a}).status!==0&&process.exit(1),t.success(`Linting completed`)}});
|