@fastkit/plugboy 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/cli.mjs +2 -0
- package/dist/chunk-QSOC5WYP.mjs +1493 -0
- package/dist/chunk-QSOC5WYP.mjs.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.mjs +142 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/dependencies/bundle-require.d.ts +1 -0
- package/dist/dependencies/bundle-require.mjs +3 -0
- package/dist/dependencies/bundle-require.mjs.map +1 -0
- package/dist/dependencies/cac.d.ts +1 -0
- package/dist/dependencies/cac.mjs +3 -0
- package/dist/dependencies/cac.mjs.map +1 -0
- package/dist/dependencies/esbuild.d.ts +1 -0
- package/dist/dependencies/esbuild.mjs +3 -0
- package/dist/dependencies/esbuild.mjs.map +1 -0
- package/dist/dependencies/glob.d.ts +1 -0
- package/dist/dependencies/glob.mjs +3 -0
- package/dist/dependencies/glob.mjs.map +1 -0
- package/dist/dependencies/inquirer.d.ts +3 -0
- package/dist/dependencies/inquirer.mjs +8 -0
- package/dist/dependencies/inquirer.mjs.map +1 -0
- package/dist/dependencies/pkg-types.d.ts +1 -0
- package/dist/dependencies/pkg-types.mjs +3 -0
- package/dist/dependencies/pkg-types.mjs.map +1 -0
- package/dist/dependencies/sort-package-json.d.ts +2 -0
- package/dist/dependencies/sort-package-json.mjs +7 -0
- package/dist/dependencies/sort-package-json.mjs.map +1 -0
- package/dist/dependencies/tsup.d.ts +1 -0
- package/dist/dependencies/tsup.mjs +3 -0
- package/dist/dependencies/tsup.mjs.map +1 -0
- package/dist/plugboy.d.ts +619 -0
- package/dist/plugboy.mjs +97 -0
- package/dist/plugboy.mjs.map +1 -0
- package/env.d.ts +35 -0
- package/package.json +93 -0
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { Options } from 'tsup';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { PackageJson } from 'pkg-types';
|
|
4
|
+
import { CompilerOptions } from 'typescript';
|
|
5
|
+
import { Plugin as Plugin$1 } from 'esbuild';
|
|
6
|
+
|
|
7
|
+
type ESBuildPluginType = NonNullable<Options['esbuildPlugins']>[number];
|
|
8
|
+
interface ESBuildPlugin extends ESBuildPluginType {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare function isPromise<T = any>(obj: any): obj is Promise<T>;
|
|
12
|
+
type Listable<T> = T | false | null | undefined | Listable<T>[] | Promise<T | false | null | undefined | Listable<T>[]>;
|
|
13
|
+
declare function resolveListable<T>(raw: Listable<T>): Promise<T[]>;
|
|
14
|
+
|
|
15
|
+
declare function getFilename(importMetaURL: string): string;
|
|
16
|
+
declare function getDirname(importMetaURL: string): string;
|
|
17
|
+
declare function isFileNotFoundException(source: unknown): source is NodeJS.ErrnoException;
|
|
18
|
+
declare function pathExists(target: string, type?: 'file' | 'dir'): Promise<boolean>;
|
|
19
|
+
type FileMatcherFn = (file: fs.Dirent, dir: string) => boolean | Promise<boolean>;
|
|
20
|
+
type FileMatcher = string | RegExp | FileMatcherFn;
|
|
21
|
+
declare function findFile(dir: string, matcher: FileMatcher, recursive?: boolean): Promise<string | undefined>;
|
|
22
|
+
interface FindConfigResult {
|
|
23
|
+
dir: string;
|
|
24
|
+
fileName: string;
|
|
25
|
+
path: string;
|
|
26
|
+
code: string;
|
|
27
|
+
}
|
|
28
|
+
interface FindConfigSettings<AllowMissing extends boolean | undefined> {
|
|
29
|
+
fileName: string | string[];
|
|
30
|
+
allowMissing?: AllowMissing;
|
|
31
|
+
test?: (result: FindConfigResult) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Trace up to how many directories above
|
|
34
|
+
* @default 10
|
|
35
|
+
*/
|
|
36
|
+
depth?: number;
|
|
37
|
+
}
|
|
38
|
+
declare function findConfig<AllowMissing extends boolean | undefined = false>(fileNameOrSettings: string | string[] | FindConfigSettings<AllowMissing>, dir?: string, currentDepth?: number): Promise<AllowMissing extends true ? FindConfigResult | null : FindConfigResult>;
|
|
39
|
+
declare function rmrf(...paths: string[]): Promise<void>;
|
|
40
|
+
declare function copyDirSync(srcDir: string, destDir: string): void;
|
|
41
|
+
|
|
42
|
+
declare function isWorkspacePackageJson(json: PackageJson): json is WorkspacePackageJson;
|
|
43
|
+
declare function resolveRawWorkspaceEntry(entry: RawWorkspaceEntry): WorkspaceEntry;
|
|
44
|
+
declare function resolveRawWorkspaceEntries(entries: RawWorkspaceEntries | undefined): WorkspaceEntries;
|
|
45
|
+
declare function resolveUserWorkspaceConfig(userConfig: UserWorkspaceConfig): Promise<ResolvedWorkspaceConfig>;
|
|
46
|
+
declare function defineWorkspaceConfig<Config extends UserWorkspaceConfig>(config: Config): Promise<ResolvedWorkspaceConfig>;
|
|
47
|
+
declare function loadWorkspaceConfig(searchDir?: string, depth?: number): Promise<ResolvedWorkspaceConfig>;
|
|
48
|
+
|
|
49
|
+
declare function resolveUserHooks(...userHooks: (UserHooks | undefined | null | false)[]): Promise<ResolvedHooks>;
|
|
50
|
+
declare function buildHooks(resolvedHooks: ResolvedHooks): BuildedHooks;
|
|
51
|
+
|
|
52
|
+
declare function resolveUserPluginOptions(pluginOptions: UserPluginOption[] | undefined): Promise<Plugin[]>;
|
|
53
|
+
declare function definePlugin<T extends Plugin>(options: T): T;
|
|
54
|
+
declare function extractProjectPlugins(searchDir?: string): Promise<Plugin[]>;
|
|
55
|
+
declare function findProjectPlugin<T extends Plugin = Plugin>(pluginName: string, searchDir?: string): Promise<T | undefined>;
|
|
56
|
+
|
|
57
|
+
declare function isProjectPackageJson(json: PackageJson): json is ProjectPackageJson;
|
|
58
|
+
declare function resolveUserProjectConfig(userConfig: UserProjectConfig): Promise<ResolvedProjectConfig>;
|
|
59
|
+
declare function defineProjectConfig<Config extends UserProjectConfig>(config: Config): Promise<ResolvedProjectConfig>;
|
|
60
|
+
declare function loadProjectConfig(searchDir?: string, depth?: number): Promise<ResolvedProjectConfig>;
|
|
61
|
+
|
|
62
|
+
declare class Path {
|
|
63
|
+
private _value;
|
|
64
|
+
private _stats?;
|
|
65
|
+
get value(): string;
|
|
66
|
+
set value(value: string);
|
|
67
|
+
get dirname(): string;
|
|
68
|
+
get basename(): string;
|
|
69
|
+
get extname(): string;
|
|
70
|
+
get stats(): fs.Stats;
|
|
71
|
+
get isDirectory(): () => boolean;
|
|
72
|
+
get isFile(): () => boolean;
|
|
73
|
+
constructor(value: string);
|
|
74
|
+
toString(): string;
|
|
75
|
+
valueOf(): string;
|
|
76
|
+
toJSON(): string;
|
|
77
|
+
relative(to: string): Path;
|
|
78
|
+
join(...paths: string[]): Path;
|
|
79
|
+
resolve(...paths: string[]): Path;
|
|
80
|
+
private _join;
|
|
81
|
+
readdir(...paths: string[]): Promise<Path[]>;
|
|
82
|
+
readFile<D = undefined>(pathAppend?: string, defaults?: D): Promise<D extends undefined ? string : string | D>;
|
|
83
|
+
readJSON<T = any, D = undefined>(pathAppend?: string, defaults?: D): Promise<D extends undefined ? T : T | D>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type RequiredPackageJSON<Field extends string> = PackageJson & Required<Pick<PackageJson, Field>>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Plugboy Project
|
|
90
|
+
*
|
|
91
|
+
* @remarks This instance is only created if the project consists of a mono-repo.
|
|
92
|
+
*/
|
|
93
|
+
declare class PlugboyProject {
|
|
94
|
+
/** Path instance of the project directory */
|
|
95
|
+
readonly dir: Path;
|
|
96
|
+
/** package.json */
|
|
97
|
+
readonly json: ProjectPackageJson;
|
|
98
|
+
/**
|
|
99
|
+
* Project Configuration
|
|
100
|
+
* @see {@link ResolvedProjectConfig}
|
|
101
|
+
*/
|
|
102
|
+
readonly config: ResolvedProjectConfig;
|
|
103
|
+
/** Names of all packages on which the project depends */
|
|
104
|
+
readonly dependencies: string[];
|
|
105
|
+
/** Directory names of all workspaces owned by the project */
|
|
106
|
+
readonly resolvedWorkspaces: string[];
|
|
107
|
+
/**
|
|
108
|
+
* Name of the project's package.json
|
|
109
|
+
*/
|
|
110
|
+
get name(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Plug-in List
|
|
113
|
+
* @see {@link ResolvedProjectConfig.plugins}
|
|
114
|
+
*/
|
|
115
|
+
get plugins(): Plugin[];
|
|
116
|
+
/**
|
|
117
|
+
* List of all user hook settings
|
|
118
|
+
* @see {@link UserHooks}
|
|
119
|
+
*/
|
|
120
|
+
get hooks(): UserHooks[];
|
|
121
|
+
constructor(ctx: ProjectSetupContext);
|
|
122
|
+
}
|
|
123
|
+
declare function getProject<AllowMissing extends boolean | undefined = false>(searchDir?: string, allowMissing?: AllowMissing, skipLoadConfig?: boolean): Promise<AllowMissing extends true ? PlugboyProject | null : PlugboyProject>;
|
|
124
|
+
|
|
125
|
+
type WorkspaceStubLink = {
|
|
126
|
+
type: 'js';
|
|
127
|
+
from: string;
|
|
128
|
+
to: string;
|
|
129
|
+
} | {
|
|
130
|
+
type: 'css';
|
|
131
|
+
from: string;
|
|
132
|
+
};
|
|
133
|
+
type WorkspaceStubLinkType = WorkspaceStubLink['type'];
|
|
134
|
+
interface WorkspaceObjectExport {
|
|
135
|
+
src: string;
|
|
136
|
+
types: string;
|
|
137
|
+
dtsDest: string;
|
|
138
|
+
import: {
|
|
139
|
+
default: string;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
interface WorkspaceExport {
|
|
143
|
+
id: string;
|
|
144
|
+
at: string | WorkspaceObjectExport;
|
|
145
|
+
stubLink?: WorkspaceStubLink;
|
|
146
|
+
}
|
|
147
|
+
declare const WORKSPACE_PACKAGE_SYNC_FIELDS: readonly ["repository", "author", "publishConfig", "license"];
|
|
148
|
+
declare function syncWorkspacePackageFields(projectJSON: ProjectPackageJson, workspaceJSON: WorkspacePackageJson): void;
|
|
149
|
+
declare class PlugboyWorkspace {
|
|
150
|
+
readonly name: string;
|
|
151
|
+
readonly dir: Path;
|
|
152
|
+
readonly config: ResolvedWorkspaceConfig;
|
|
153
|
+
readonly project: PlugboyProject | null;
|
|
154
|
+
readonly dirs: WorkspaceDirs;
|
|
155
|
+
readonly dependencies: string[];
|
|
156
|
+
readonly projectDependencies: string[];
|
|
157
|
+
readonly meta: WorkspaceMeta;
|
|
158
|
+
readonly entry: Record<string, string>;
|
|
159
|
+
readonly exports: WorkspaceExport[];
|
|
160
|
+
readonly builder: Builder;
|
|
161
|
+
readonly plugins: Plugin[];
|
|
162
|
+
readonly hooks: BuildedHooks;
|
|
163
|
+
readonly dtsFiles: string[];
|
|
164
|
+
readonly dts: NormalizedDTSSettings;
|
|
165
|
+
private _json;
|
|
166
|
+
get json(): WorkspacePackageJson;
|
|
167
|
+
constructor(ctx: WorkspaceSetupContext);
|
|
168
|
+
clean(withDepsAndCache?: boolean): Promise<void>;
|
|
169
|
+
preparePackageJSON(): Promise<WorkspacePackageJson>;
|
|
170
|
+
getStubLinks(): WorkspaceStubLink[];
|
|
171
|
+
stub(): Promise<void>;
|
|
172
|
+
getESBuildPlugins(): Promise<ESBuildPlugin[]>;
|
|
173
|
+
build(): Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
declare function getWorkspace<AllowMissing extends boolean | undefined = false>(searchDir?: string, allowMissing?: AllowMissing): Promise<AllowMissing extends true ? PlugboyWorkspace | null : PlugboyWorkspace>;
|
|
176
|
+
|
|
177
|
+
interface ResolvedOptions extends Options {
|
|
178
|
+
esbuildPlugins: Plugin$1[];
|
|
179
|
+
}
|
|
180
|
+
declare class Builder {
|
|
181
|
+
readonly workspace: PlugboyWorkspace;
|
|
182
|
+
private _tsupOptions?;
|
|
183
|
+
get entry(): Record<string, string>;
|
|
184
|
+
get dts(): NormalizedDTSSettings;
|
|
185
|
+
constructor(workspace: PlugboyWorkspace);
|
|
186
|
+
tsupOptions(overrides?: {
|
|
187
|
+
watch?: boolean;
|
|
188
|
+
}): Promise<ResolvedOptions>;
|
|
189
|
+
private _stubLinkJS;
|
|
190
|
+
private _stubLinkCSS;
|
|
191
|
+
copyPublicDir(): Promise<void>;
|
|
192
|
+
stub(): Promise<void>;
|
|
193
|
+
normalizeDTSBySettings(dts: string, settings: NormalizedDTSPreserveTypeSettings): string | undefined;
|
|
194
|
+
normalizeDTSFile(filePath: string): Promise<void>;
|
|
195
|
+
normalizeDTSFiles(dtsFiles?: string[]): Promise<void>;
|
|
196
|
+
emitInlineDTS(): Promise<void>;
|
|
197
|
+
build(): Promise<void>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare function generateWorkspace(workspaceName?: string, cwd?: string): Promise<void>;
|
|
201
|
+
|
|
202
|
+
type ESBuildPluginOption = ESBuildPlugin | undefined | false | null | Promise<ESBuildPlugin | undefined | false | null> | ((workspace: PlugboyWorkspace) => ESBuildPlugin | undefined | false | null | Promise<ESBuildPlugin | undefined | false | null>);
|
|
203
|
+
interface Plugin {
|
|
204
|
+
name: string;
|
|
205
|
+
hooks?: UserHooks;
|
|
206
|
+
esbuildPlugins?: ESBuildPluginOption[];
|
|
207
|
+
}
|
|
208
|
+
type UserPluginOption = Listable<Plugin>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Type preservation target in d.ts file
|
|
212
|
+
*/
|
|
213
|
+
interface DTSPreserveTypeTarget {
|
|
214
|
+
/** Type name */
|
|
215
|
+
typeName: string;
|
|
216
|
+
/**
|
|
217
|
+
* String to be restored or regular expression to match
|
|
218
|
+
*/
|
|
219
|
+
from: string | RegExp;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Type preservation target in d.ts file (normalized)
|
|
223
|
+
*
|
|
224
|
+
* @see {@link DTSPreserveTypeTarget}
|
|
225
|
+
*/
|
|
226
|
+
interface NormalizedDTSPreserveTypeTarget extends Omit<DTSPreserveTypeTarget, 'from'> {
|
|
227
|
+
/** Regular expression to match the string to be restored */
|
|
228
|
+
from: RegExp;
|
|
229
|
+
}
|
|
230
|
+
declare function normalizeDTSPreserveTypeTarget(target: DTSPreserveTypeTarget): NormalizedDTSPreserveTypeTarget;
|
|
231
|
+
/**
|
|
232
|
+
* Type preservation setting for d.ts files
|
|
233
|
+
*
|
|
234
|
+
* @remarks This setting is for restoring type information inlined by the TypeScript compiler to the original type name by string substitution.
|
|
235
|
+
*/
|
|
236
|
+
interface DTSPreserveTypeSettings {
|
|
237
|
+
/** Name of the package to which the type to be restored belongs */
|
|
238
|
+
pkg?: string;
|
|
239
|
+
/** List of preservation targets */
|
|
240
|
+
targets: DTSPreserveTypeTarget[];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Type preservation setting for d.ts files (normalized)
|
|
244
|
+
*
|
|
245
|
+
* @see {@link DTSPreserveTypeSettings}
|
|
246
|
+
*/
|
|
247
|
+
interface NormalizedDTSPreserveTypeSettings extends Omit<DTSPreserveTypeSettings, 'targets'> {
|
|
248
|
+
/** List of normalized type preservation targets */
|
|
249
|
+
targets: NormalizedDTSPreserveTypeTarget[];
|
|
250
|
+
}
|
|
251
|
+
declare function normalizeDTSPreserveTypeSettings(settings: DTSPreserveTypeSettings): NormalizedDTSPreserveTypeSettings;
|
|
252
|
+
/**
|
|
253
|
+
* d.ts output setting
|
|
254
|
+
*/
|
|
255
|
+
interface DTSSettings {
|
|
256
|
+
/**
|
|
257
|
+
* Inline output without bundling d.ts
|
|
258
|
+
*
|
|
259
|
+
* @default false
|
|
260
|
+
*/
|
|
261
|
+
inline?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* list of type preservation settings
|
|
264
|
+
*
|
|
265
|
+
* @remarks This setting is for restoring type information inlined by the TypeScript compiler to the original type name by string substitution.
|
|
266
|
+
*
|
|
267
|
+
* @see {@link DTSPreserveTypeSettings}
|
|
268
|
+
*/
|
|
269
|
+
preserveType?: DTSPreserveTypeSettings[];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* d.ts output setting (normalized)
|
|
273
|
+
*
|
|
274
|
+
* @see {@link DTSSettings}
|
|
275
|
+
*/
|
|
276
|
+
interface NormalizedDTSSettings {
|
|
277
|
+
/**
|
|
278
|
+
* Inline output without bundling d.ts
|
|
279
|
+
*/
|
|
280
|
+
inline: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* list of type preservation settings
|
|
283
|
+
*/
|
|
284
|
+
preserveType: NormalizedDTSPreserveTypeSettings[];
|
|
285
|
+
}
|
|
286
|
+
declare function normalizeDTSSettings(settings: DTSSettings): NormalizedDTSSettings;
|
|
287
|
+
declare function mergeDTSSettingsList(...settingsList: (DTSSettings | undefined)[]): NormalizedDTSSettings;
|
|
288
|
+
|
|
289
|
+
declare const WORKSPACE_REQUIRED_FIELDS: readonly ["name", "version"];
|
|
290
|
+
type WorkspaceRequiredField = (typeof WORKSPACE_REQUIRED_FIELDS)[number];
|
|
291
|
+
/**
|
|
292
|
+
* Entry setting object
|
|
293
|
+
*/
|
|
294
|
+
interface RawWorkspaceEntryObject {
|
|
295
|
+
/**
|
|
296
|
+
* Entry file path
|
|
297
|
+
*
|
|
298
|
+
* @remarks It must be relative to the root directory of the workspace.
|
|
299
|
+
*/
|
|
300
|
+
src: string;
|
|
301
|
+
/**
|
|
302
|
+
* Set to true if the entry outputs css at the same time
|
|
303
|
+
*
|
|
304
|
+
* @remarks By doing this, the exports field in package.json will be set automatically.
|
|
305
|
+
*/
|
|
306
|
+
css?: boolean;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Entry setting object
|
|
310
|
+
*/
|
|
311
|
+
type WorkspaceEntry = Required<RawWorkspaceEntryObject>;
|
|
312
|
+
type RawWorkspaceEntry = string | RawWorkspaceEntryObject;
|
|
313
|
+
/**
|
|
314
|
+
* Configuration of all entries in the workspace (normalized)
|
|
315
|
+
*
|
|
316
|
+
* @see {@link RawWorkspaceEntries}
|
|
317
|
+
*/
|
|
318
|
+
type WorkspaceEntries = Record<string, WorkspaceEntry>;
|
|
319
|
+
/**
|
|
320
|
+
* Configuration of all entries in the workspace
|
|
321
|
+
*
|
|
322
|
+
* @remarks The configuration must be `{ [id]: [Entry setting: }`. `"." ` is treated as a special ID and is the target of the main export.
|
|
323
|
+
*/
|
|
324
|
+
type RawWorkspaceEntries = Record<string, RawWorkspaceEntry>;
|
|
325
|
+
declare const TSUP_SYNC_OPTIONS: readonly ["define", "noExternal", "external", "replaceNodeEnv", "skipNodeModulesBundle"];
|
|
326
|
+
type TSUpSyncOption = (typeof TSUP_SYNC_OPTIONS)[number];
|
|
327
|
+
interface TSUpSyncOptions extends Pick<Options, TSUpSyncOption> {
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Workspace User Configuration
|
|
331
|
+
*/
|
|
332
|
+
interface UserWorkspaceConfig extends TSUpSyncOptions {
|
|
333
|
+
/**
|
|
334
|
+
* Ignore project settings
|
|
335
|
+
*
|
|
336
|
+
* @remarks Normally, when processing a workspace, plugboy looks for and merges the settings of the entire project at the same time, but this action can be canceled.
|
|
337
|
+
*/
|
|
338
|
+
ignoreProjectConfig?: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Configuration of all entries in the workspace
|
|
341
|
+
*
|
|
342
|
+
* @see {@link RawWorkspaceEntries}
|
|
343
|
+
*/
|
|
344
|
+
entries?: RawWorkspaceEntries;
|
|
345
|
+
/**
|
|
346
|
+
* Hook Setting
|
|
347
|
+
* @see {@link UserHooks}
|
|
348
|
+
*/
|
|
349
|
+
hooks?: UserHooks;
|
|
350
|
+
/**
|
|
351
|
+
* Plug-in List
|
|
352
|
+
* @see {@link UserPluginOption}
|
|
353
|
+
*/
|
|
354
|
+
plugins?: UserPluginOption[];
|
|
355
|
+
/**
|
|
356
|
+
* d.ts output setting
|
|
357
|
+
* @see {@link DTSSettings}
|
|
358
|
+
*/
|
|
359
|
+
dts?: DTSSettings;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Workspace Configuration
|
|
363
|
+
*/
|
|
364
|
+
interface ResolvedWorkspaceConfig extends Required<Omit<UserWorkspaceConfig, 'entries' | 'hooks' | 'plugins' | 'dts' | TSUpSyncOption>>, TSUpSyncOptions {
|
|
365
|
+
/**
|
|
366
|
+
* Configuration of all entries in the workspace
|
|
367
|
+
*
|
|
368
|
+
* @see {@link WorkspaceEntries}
|
|
369
|
+
*/
|
|
370
|
+
entries: WorkspaceEntries;
|
|
371
|
+
/**
|
|
372
|
+
* Hook Setting
|
|
373
|
+
* @see {@link UserHooks}
|
|
374
|
+
*/
|
|
375
|
+
hooks?: UserHooks;
|
|
376
|
+
/**
|
|
377
|
+
* Plug-in List
|
|
378
|
+
* @see {@link UserPluginOption}
|
|
379
|
+
*/
|
|
380
|
+
plugins: Plugin[];
|
|
381
|
+
/**
|
|
382
|
+
* d.ts output setting
|
|
383
|
+
* @see {@link DTSSettings}
|
|
384
|
+
*/
|
|
385
|
+
dts?: DTSSettings;
|
|
386
|
+
}
|
|
387
|
+
type WorkspacePackageJson = RequiredPackageJSON<WorkspaceRequiredField>;
|
|
388
|
+
/**
|
|
389
|
+
* Workspace Directory Settings
|
|
390
|
+
*/
|
|
391
|
+
interface WorkspaceDirs {
|
|
392
|
+
/** Path instance of the source directory */
|
|
393
|
+
src: Path;
|
|
394
|
+
/** Path instance of the distribution directory */
|
|
395
|
+
dist: Path;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Workspace Meta Information
|
|
399
|
+
*
|
|
400
|
+
* @remarks This will be set to a value uniquely extended by the plugin
|
|
401
|
+
*/
|
|
402
|
+
interface WorkspaceMeta {
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Workspace setup context object
|
|
406
|
+
* @remarks Objects that are configured when the workspace is set up. Customization can be done before the workspace instance is created by a plug-in or other process.
|
|
407
|
+
*/
|
|
408
|
+
interface WorkspaceSetupContext {
|
|
409
|
+
/** Workspace directory path instance */
|
|
410
|
+
dir: Path;
|
|
411
|
+
/** package.json */
|
|
412
|
+
json: WorkspacePackageJson;
|
|
413
|
+
/**
|
|
414
|
+
* Workspace Configuration
|
|
415
|
+
* @see {@link ResolvedWorkspaceConfig}
|
|
416
|
+
*/
|
|
417
|
+
config: ResolvedWorkspaceConfig;
|
|
418
|
+
/** Plugboy Project */
|
|
419
|
+
project: PlugboyProject | null;
|
|
420
|
+
/** Workspace Directory Settings */
|
|
421
|
+
dirs: WorkspaceDirs;
|
|
422
|
+
/**
|
|
423
|
+
* All package names on which the workspace depends
|
|
424
|
+
*/
|
|
425
|
+
dependencies: string[];
|
|
426
|
+
/**
|
|
427
|
+
* Names of all in-project packages on which the workspace depends
|
|
428
|
+
*/
|
|
429
|
+
projectDependencies: string[];
|
|
430
|
+
/**
|
|
431
|
+
* Workspace Meta Information
|
|
432
|
+
* @see {@link WorkspaceMeta}
|
|
433
|
+
*/
|
|
434
|
+
meta: WorkspaceMeta;
|
|
435
|
+
/**
|
|
436
|
+
* プラグインリスト
|
|
437
|
+
* @see {@link Plugin}
|
|
438
|
+
*/
|
|
439
|
+
plugins: Plugin[];
|
|
440
|
+
/**
|
|
441
|
+
* Map of hook methods that can be initialized and called
|
|
442
|
+
* @see {@link BuildedHooks}
|
|
443
|
+
*/
|
|
444
|
+
hooks: BuildedHooks;
|
|
445
|
+
/**
|
|
446
|
+
* d.ts output setting
|
|
447
|
+
* @see {@link NormalizedDTSSettings}
|
|
448
|
+
*/
|
|
449
|
+
dts: NormalizedDTSSettings;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** plugboy hook definition */
|
|
453
|
+
interface HookTypes {
|
|
454
|
+
/**
|
|
455
|
+
* Hooks during workspace setup
|
|
456
|
+
* @remarks Called just before the workspace instance is created
|
|
457
|
+
* @param ctx - {@link WorkspaceSetupContext Workspace setup context object}
|
|
458
|
+
*/
|
|
459
|
+
setupWorkspace: (ctx: WorkspaceSetupContext) => any;
|
|
460
|
+
/**
|
|
461
|
+
* Hooks after workspace generation
|
|
462
|
+
* @param workspace - {@link PlugboyWorkspace workspace instance}
|
|
463
|
+
*/
|
|
464
|
+
createWorkspace: (workspace: PlugboyWorkspace) => any;
|
|
465
|
+
/**
|
|
466
|
+
* Hooks when correcting package.json
|
|
467
|
+
* @param json - package.json just before it was modified and saved by the plugboy
|
|
468
|
+
* @param workspace - {@link PlugboyWorkspace workspace instance}
|
|
469
|
+
*/
|
|
470
|
+
preparePackageJSON: (json: WorkspacePackageJson, workspace: PlugboyWorkspace) => any;
|
|
471
|
+
}
|
|
472
|
+
declare function createHooksDefaults(): ResolvedHooks;
|
|
473
|
+
type HookName = keyof HookTypes;
|
|
474
|
+
/**
|
|
475
|
+
* plugboy user hook definition
|
|
476
|
+
* @see {@link HookTypes}
|
|
477
|
+
*/
|
|
478
|
+
type UserHooks = {
|
|
479
|
+
[Name in HookName]?: Listable<HookTypes[Name]>;
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* Pre-setup hook definitions
|
|
483
|
+
* @see {@link HookTypes}
|
|
484
|
+
*/
|
|
485
|
+
type ResolvedHooks = {
|
|
486
|
+
[Name in HookName]: HookTypes[Name][];
|
|
487
|
+
};
|
|
488
|
+
type HookArgs<Name extends HookName> = Parameters<HookTypes[Name]>;
|
|
489
|
+
type UnPromisify<T> = T extends Promise<infer U> ? U : T;
|
|
490
|
+
type HookReturnType<Name extends HookName> = UnPromisify<ReturnType<HookTypes[Name]>>;
|
|
491
|
+
/**
|
|
492
|
+
* Map of hook methods that can be initialized and called
|
|
493
|
+
* @see {@link HookTypes}
|
|
494
|
+
*/
|
|
495
|
+
type BuildedHooks = {
|
|
496
|
+
[Name in HookName]: (...args: HookArgs<Name>) => Promise<HookReturnType<Name>>;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
declare const PROJECT_REQUIRED_FIELDS: readonly ["name"];
|
|
500
|
+
type ProjectRequiredField = (typeof PROJECT_REQUIRED_FIELDS)[number];
|
|
501
|
+
type TSConfigJSON = {
|
|
502
|
+
compilerOptions?: CompilerOptions;
|
|
503
|
+
} & Record<string, any>;
|
|
504
|
+
/**
|
|
505
|
+
* Template for package.json script in workspace
|
|
506
|
+
*/
|
|
507
|
+
interface ProjectScriptsTemplate {
|
|
508
|
+
/** Template Name */
|
|
509
|
+
name: string;
|
|
510
|
+
/** Script Map */
|
|
511
|
+
scripts: Record<string, string>;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Project User Configuration
|
|
515
|
+
*/
|
|
516
|
+
interface UserProjectConfig {
|
|
517
|
+
/**
|
|
518
|
+
* Directory where the workspace is located
|
|
519
|
+
* @remarks Used to create a new workspace with the `plugboy gen` CLI command.
|
|
520
|
+
* @default packages
|
|
521
|
+
*/
|
|
522
|
+
workspacesDir?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Workspace script templates, or a list of them
|
|
525
|
+
* @remarks Used to create a new workspace with the `plugboy gen` CLI command.
|
|
526
|
+
*/
|
|
527
|
+
scripts?: Record<string, string> | ProjectScriptsTemplate[];
|
|
528
|
+
/**
|
|
529
|
+
* Workspace tsconfig template
|
|
530
|
+
* @remarks Used to create a new workspace with the `plugboy gen` CLI command.
|
|
531
|
+
*/
|
|
532
|
+
tsconfig?: TSConfigJSON;
|
|
533
|
+
/**
|
|
534
|
+
* Workspace README template
|
|
535
|
+
* @remarks Used to create a new workspace with the `plugboy gen` CLI command.
|
|
536
|
+
*/
|
|
537
|
+
readme?: (json: WorkspacePackageJson) => string;
|
|
538
|
+
/**
|
|
539
|
+
* Fixes the version of all peer dependencies in the project
|
|
540
|
+
*/
|
|
541
|
+
peerDependencies?: Record<string, string>;
|
|
542
|
+
/**
|
|
543
|
+
* Hook Setting
|
|
544
|
+
* @see {@link UserHooks}
|
|
545
|
+
*/
|
|
546
|
+
hooks?: UserHooks;
|
|
547
|
+
/**
|
|
548
|
+
* Plug-in List
|
|
549
|
+
* @see {@link UserPluginOption}
|
|
550
|
+
*/
|
|
551
|
+
plugins?: UserPluginOption[];
|
|
552
|
+
/**
|
|
553
|
+
* d.ts output setting
|
|
554
|
+
* @see {@link DTSSettings}
|
|
555
|
+
*/
|
|
556
|
+
dts?: DTSSettings;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Project Configuration
|
|
560
|
+
*/
|
|
561
|
+
interface ResolvedProjectConfig extends Required<Omit<UserProjectConfig, 'scripts' | 'tsconfig' | 'hooks' | 'plugins' | 'dts'>> {
|
|
562
|
+
/**
|
|
563
|
+
* Workspace script templates list
|
|
564
|
+
* @remarks Used to create a new workspace with the `plugboy gen` CLI command.
|
|
565
|
+
*/
|
|
566
|
+
scripts: ProjectScriptsTemplate[];
|
|
567
|
+
/**
|
|
568
|
+
* Workspace tsconfig template
|
|
569
|
+
* @remarks Used to create a new workspace with the `plugboy gen` CLI command.
|
|
570
|
+
*/
|
|
571
|
+
tsconfig?: TSConfigJSON;
|
|
572
|
+
/**
|
|
573
|
+
* Hook Setting
|
|
574
|
+
* @see {@link UserHooks}
|
|
575
|
+
*/
|
|
576
|
+
hooks?: UserHooks;
|
|
577
|
+
/**
|
|
578
|
+
* Plug-in List
|
|
579
|
+
* @see {@link UserPluginOption}
|
|
580
|
+
*/
|
|
581
|
+
plugins: Plugin[];
|
|
582
|
+
/**
|
|
583
|
+
* d.ts output setting
|
|
584
|
+
* @see {@link DTSSettings}
|
|
585
|
+
*/
|
|
586
|
+
dts?: DTSSettings;
|
|
587
|
+
}
|
|
588
|
+
type ProjectPackageJson = RequiredPackageJSON<ProjectRequiredField>;
|
|
589
|
+
/**
|
|
590
|
+
* Project setup context object
|
|
591
|
+
* @remarks Objects that are configured when the project is set up.
|
|
592
|
+
*/
|
|
593
|
+
interface ProjectSetupContext {
|
|
594
|
+
/** Project directory path instance */
|
|
595
|
+
dir: Path;
|
|
596
|
+
/** package.json */
|
|
597
|
+
json: ProjectPackageJson;
|
|
598
|
+
/** Project Configuration */
|
|
599
|
+
config: ResolvedProjectConfig;
|
|
600
|
+
/**
|
|
601
|
+
* List of directory names of workspaces located in the project
|
|
602
|
+
* @remarks Note that it is the directory name, not the package name.
|
|
603
|
+
*/
|
|
604
|
+
resolvedWorkspaces: string[];
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
interface GetProjectPackageJsonResult {
|
|
608
|
+
dir: Path;
|
|
609
|
+
json: ProjectPackageJson;
|
|
610
|
+
}
|
|
611
|
+
declare function getProjectPackageJson<AllowMissing extends boolean | undefined = false>(searchDir?: string, allowMissing?: AllowMissing): Promise<AllowMissing extends true ? GetProjectPackageJsonResult | null : GetProjectPackageJsonResult>;
|
|
612
|
+
interface GetWorkspacePackageJsonResult {
|
|
613
|
+
dir: Path;
|
|
614
|
+
json: WorkspacePackageJson;
|
|
615
|
+
}
|
|
616
|
+
declare function getWorkspacePackageJson<AllowMissing extends boolean | undefined = false>(searchDir?: string, allowMissing?: AllowMissing): Promise<AllowMissing extends true ? GetWorkspacePackageJsonResult | null : GetWorkspacePackageJsonResult>;
|
|
617
|
+
declare function findWorkspacePackages(dir: string): Promise<GetWorkspacePackageJsonResult[]>;
|
|
618
|
+
|
|
619
|
+
export { BuildedHooks, Builder, DTSPreserveTypeSettings, DTSPreserveTypeTarget, DTSSettings, ESBuildPlugin, ESBuildPluginOption, FindConfigResult, GetProjectPackageJsonResult, GetWorkspacePackageJsonResult, HookArgs, HookName, HookReturnType, HookTypes, Listable, NormalizedDTSPreserveTypeSettings, NormalizedDTSPreserveTypeTarget, NormalizedDTSSettings, PROJECT_REQUIRED_FIELDS, Path, PlugboyProject, PlugboyWorkspace, Plugin, ProjectPackageJson, ProjectScriptsTemplate, ProjectSetupContext, RawWorkspaceEntries, RawWorkspaceEntry, RawWorkspaceEntryObject, ResolvedHooks, ResolvedProjectConfig, ResolvedWorkspaceConfig, TSConfigJSON, TSUP_SYNC_OPTIONS, UnPromisify, UserHooks, UserPluginOption, UserProjectConfig, UserWorkspaceConfig, WORKSPACE_PACKAGE_SYNC_FIELDS, WORKSPACE_REQUIRED_FIELDS, WorkspaceDirs, WorkspaceEntries, WorkspaceEntry, WorkspaceExport, WorkspaceMeta, WorkspaceObjectExport, WorkspacePackageJson, WorkspaceSetupContext, WorkspaceStubLink, WorkspaceStubLinkType, buildHooks, copyDirSync, createHooksDefaults, definePlugin, defineProjectConfig, defineWorkspaceConfig, extractProjectPlugins, findConfig, findFile, findProjectPlugin, findWorkspacePackages, generateWorkspace, getDirname, getFilename, getProject, getProjectPackageJson, getWorkspace, getWorkspacePackageJson, isFileNotFoundException, isProjectPackageJson, isPromise, isWorkspacePackageJson, loadProjectConfig, loadWorkspaceConfig, mergeDTSSettingsList, normalizeDTSPreserveTypeSettings, normalizeDTSPreserveTypeTarget, normalizeDTSSettings, pathExists, resolveListable, resolveRawWorkspaceEntries, resolveRawWorkspaceEntry, resolveUserHooks, resolveUserPluginOptions, resolveUserProjectConfig, resolveUserWorkspaceConfig, rmrf, syncWorkspacePackageFields };
|