@backstage/cli-node 0.3.6-next.2 → 0.3.7-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cli-internal/src/InternalCliModule.cjs.js +21 -0
- package/dist/cli-internal/src/InternalCliModule.cjs.js.map +1 -1
- package/dist/cli-internal/src/InternalCommandNode.cjs.js +4 -2
- package/dist/cli-internal/src/InternalCommandNode.cjs.js.map +1 -1
- package/dist/cli-module/CommandGraph.cjs.js +14 -9
- package/dist/cli-module/CommandGraph.cjs.js.map +1 -1
- package/dist/cli-module/createCliModule.cjs.js +16 -1
- package/dist/cli-module/createCliModule.cjs.js.map +1 -1
- package/dist/cli-module/resolveCommandVariant.cjs.js +78 -0
- package/dist/cli-module/resolveCommandVariant.cjs.js.map +1 -0
- package/dist/cli-module/runCli.cjs.js +8 -6
- package/dist/cli-module/runCli.cjs.js.map +1 -1
- package/dist/index.d.ts +497 -441
- package/dist/monorepo/PackageGraph.cjs.js +2 -1
- package/dist/monorepo/PackageGraph.cjs.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -75,589 +75,645 @@ declare class SuccessCache {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* Returns true if the current project is a monorepo.
|
|
79
79
|
*
|
|
80
|
-
*
|
|
80
|
+
* Uses a simple presence check on the `workspaces` field. Empty or invalid
|
|
81
|
+
* workspace config is treated as a monorepo; we do not validate patterns.
|
|
81
82
|
*
|
|
82
83
|
* @public
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* The remaining arguments passed to the command after the command path
|
|
87
|
-
* has been resolved. This includes both positional arguments and flags.
|
|
88
|
-
*
|
|
89
|
-
* For example, running `backstage-cli repo test --verbose src/` would
|
|
90
|
-
* result in `args` being `['--verbose', 'src/']`.
|
|
91
|
-
*/
|
|
92
|
-
args: string[];
|
|
93
|
-
/**
|
|
94
|
-
* Metadata about the command being executed.
|
|
95
|
-
*/
|
|
96
|
-
info: {
|
|
97
|
-
/**
|
|
98
|
-
* The full usage string of the command including the program name,
|
|
99
|
-
* for example `"backstage-cli repo test"`.
|
|
100
|
-
*/
|
|
101
|
-
usage: string;
|
|
102
|
-
/**
|
|
103
|
-
* The name of the command as defined by its path,
|
|
104
|
-
* for example `"repo test"`.
|
|
105
|
-
*/
|
|
106
|
-
name: string;
|
|
107
|
-
};
|
|
108
|
-
}
|
|
85
|
+
declare function isMonoRepo(): Promise<boolean>;
|
|
86
|
+
|
|
109
87
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* Each command is identified by a `path` that determines its position in
|
|
113
|
-
* the command tree. For example, a path of `['repo', 'test']` registers
|
|
114
|
-
* the command as `backstage-cli repo test`.
|
|
115
|
-
*
|
|
116
|
-
* Commands can either provide an `execute` function directly, or use a
|
|
117
|
-
* `loader` for deferred loading of the implementation. The loader pattern
|
|
118
|
-
* is recommended for commands with heavy dependencies, as it avoids
|
|
119
|
-
* loading the implementation until the command is actually invoked.
|
|
88
|
+
* Backstage package role, see {@link https://backstage.io/docs/tooling/cli/build-system#package-roles | docs}.
|
|
120
89
|
*
|
|
121
90
|
* @public
|
|
122
91
|
*/
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* The path segments that define the command's position in the CLI tree.
|
|
126
|
-
* For example, `['repo', 'test']` maps to `backstage-cli repo test`.
|
|
127
|
-
*/
|
|
128
|
-
path: string[];
|
|
129
|
-
/**
|
|
130
|
-
* A short description of the command, displayed in help output.
|
|
131
|
-
*/
|
|
132
|
-
description: string;
|
|
133
|
-
/**
|
|
134
|
-
* If `true`, the command is deprecated and will be hidden from help output
|
|
135
|
-
* but can still be invoked.
|
|
136
|
-
*/
|
|
137
|
-
deprecated?: boolean;
|
|
138
|
-
/**
|
|
139
|
-
* If `true`, the command is experimental and will be hidden from help
|
|
140
|
-
* output but can still be invoked.
|
|
141
|
-
*/
|
|
142
|
-
experimental?: boolean;
|
|
143
|
-
/**
|
|
144
|
-
* The command implementation, either as a direct function or as a loader
|
|
145
|
-
* that returns the implementation as a default export. The loader form
|
|
146
|
-
* is useful for deferring heavy imports until the command is invoked.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* Direct execution:
|
|
150
|
-
* ```
|
|
151
|
-
* execute: async ({ args }) => { ... }
|
|
152
|
-
* ```
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* Deferred loading:
|
|
156
|
-
* ```
|
|
157
|
-
* execute: { loader: () => import('./my-command') }
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
execute: ((context: CliCommandContext) => Promise<void>) | {
|
|
161
|
-
loader: () => Promise<{
|
|
162
|
-
default: (context: CliCommandContext) => Promise<void>;
|
|
163
|
-
}>;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
92
|
+
type PackageRole = 'frontend' | 'backend' | 'cli' | 'cli-module' | 'web-library' | 'node-library' | 'common-library' | 'frontend-plugin' | 'frontend-plugin-module' | 'backend-plugin' | 'backend-plugin-module';
|
|
166
93
|
/**
|
|
167
|
-
*
|
|
168
|
-
* using {@link createCliModule}.
|
|
94
|
+
* A type of platform that a package can be built for.
|
|
169
95
|
*
|
|
170
96
|
* @public
|
|
171
97
|
*/
|
|
172
|
-
|
|
173
|
-
readonly $$type: '@backstage/CliModule';
|
|
174
|
-
}
|
|
175
|
-
|
|
98
|
+
type PackagePlatform = 'node' | 'web' | 'common';
|
|
176
99
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* The `init` callback is invoked immediately at creation time and is used
|
|
180
|
-
* to register commands via the provided registry. The commands are then
|
|
181
|
-
* made available to the CLI host once the returned promise resolves.
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* ```
|
|
185
|
-
* import { createCliModule } from '@backstage/cli-node';
|
|
186
|
-
* import packageJson from '../package.json';
|
|
187
|
-
*
|
|
188
|
-
* export default createCliModule({
|
|
189
|
-
* packageJson,
|
|
190
|
-
* init: async reg => {
|
|
191
|
-
* reg.addCommand({
|
|
192
|
-
* path: ['repo', 'test'],
|
|
193
|
-
* description: 'Run tests across the repository',
|
|
194
|
-
* execute: { loader: () => import('./commands/test') },
|
|
195
|
-
* });
|
|
196
|
-
* },
|
|
197
|
-
* });
|
|
198
|
-
* ```
|
|
100
|
+
* The type of output that a package can produce.
|
|
199
101
|
*
|
|
200
102
|
* @public
|
|
201
103
|
*/
|
|
202
|
-
|
|
203
|
-
/** The `package.json` contents of the plugin package, used to identify the plugin. */
|
|
204
|
-
packageJson: {
|
|
205
|
-
name: string;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* An initialization callback that registers commands with the CLI.
|
|
209
|
-
* Called immediately when the plugin is created.
|
|
210
|
-
*/
|
|
211
|
-
init: (registry: {
|
|
212
|
-
/** Registers a new command with the CLI. */
|
|
213
|
-
addCommand: (command: CliCommand) => void;
|
|
214
|
-
}) => Promise<void>;
|
|
215
|
-
}): CliModule;
|
|
216
|
-
|
|
104
|
+
type PackageOutputType = 'bundle' | 'types' | 'esm' | 'cjs';
|
|
217
105
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* This is intended for creating custom CLI packages from a fixed set of
|
|
221
|
-
* directly imported modules. Module discovery and override behavior are left
|
|
222
|
-
* to the caller.
|
|
223
|
-
*
|
|
224
|
-
* Invoking the program or a command group without a subcommand displays
|
|
225
|
-
* help for that level and completes successfully. Command groups and commands
|
|
226
|
-
* are listed separately in alphabetical order. Group previews fit the terminal width
|
|
227
|
-
* (80 columns when unavailable), expanding nested groups breadth-first when space
|
|
228
|
-
* permits. Unexpanded groups have a trailing slash; truncated previews end in an ellipsis.
|
|
229
|
-
*
|
|
230
|
-
* When a command completes without throwing, the process exits with
|
|
231
|
-
* `process.exitCode`, or `0` if it is not set. Commands can set
|
|
232
|
-
* `process.exitCode` to report a failure, such as invalid input, without
|
|
233
|
-
* throwing an error.
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* ```ts
|
|
237
|
-
* import { runCli } from '@backstage/cli-node';
|
|
238
|
-
* import buildModule from '@backstage/cli-module-build';
|
|
239
|
-
* import testModule from '@backstage/cli-module-test-jest';
|
|
240
|
-
* import packageJson from '../package.json';
|
|
241
|
-
*
|
|
242
|
-
* runCli({
|
|
243
|
-
* modules: [buildModule, testModule],
|
|
244
|
-
* name: packageJson.name,
|
|
245
|
-
* version: packageJson.version,
|
|
246
|
-
* });
|
|
247
|
-
* ```
|
|
106
|
+
* Information about a package role.
|
|
248
107
|
*
|
|
249
108
|
* @public
|
|
250
109
|
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
/** The version string shown when `--version` is passed. */
|
|
257
|
-
version?: string;
|
|
258
|
-
}): Promise<void>;
|
|
110
|
+
interface PackageRoleInfo {
|
|
111
|
+
role: PackageRole;
|
|
112
|
+
platform: PackagePlatform;
|
|
113
|
+
output: PackageOutputType[];
|
|
114
|
+
}
|
|
259
115
|
|
|
260
116
|
/**
|
|
261
|
-
*
|
|
117
|
+
* Utilities for working with Backstage package roles.
|
|
262
118
|
*
|
|
263
|
-
* @deprecated Use {@link runCli} with a single entry in the `modules` array instead.
|
|
264
119
|
* @public
|
|
265
120
|
*/
|
|
266
|
-
declare
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
|
|
273
|
-
|
|
121
|
+
declare class PackageRoles {
|
|
122
|
+
/**
|
|
123
|
+
* Get the associated info for a package role.
|
|
124
|
+
*/
|
|
125
|
+
static getRoleInfo(role: string): PackageRoleInfo;
|
|
126
|
+
/**
|
|
127
|
+
* Given package JSON data, get the package role.
|
|
128
|
+
*/
|
|
129
|
+
static getRoleFromPackage(pkgJson: unknown): PackageRole | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Attempt to detect the role of a package from its package.json.
|
|
132
|
+
*/
|
|
133
|
+
static detectRoleFromPackage(pkgJson: unknown): PackageRole | undefined;
|
|
134
|
+
}
|
|
274
135
|
|
|
275
136
|
/**
|
|
276
|
-
*
|
|
137
|
+
* A list of the feature types we want to extract from the project
|
|
138
|
+
* and include in the metadata
|
|
277
139
|
*
|
|
278
140
|
* @public
|
|
279
141
|
*/
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Decides the number of concurrent workers by multiplying
|
|
283
|
-
* this with the configured concurrency.
|
|
284
|
-
*
|
|
285
|
-
* Defaults to 1.
|
|
286
|
-
*/
|
|
287
|
-
concurrencyFactor?: number;
|
|
288
|
-
items: Iterable<TItem>;
|
|
289
|
-
worker: (item: TItem) => Promise<void>;
|
|
290
|
-
};
|
|
142
|
+
declare const packageFeatureType: readonly ["@backstage/BackendFeature", "@backstage/BackstagePlugin", "@backstage/FrontendPlugin", "@backstage/FrontendModule", "@backstage/FrontendFeatureLoader"];
|
|
291
143
|
/**
|
|
292
|
-
*
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
type BackstagePackageFeatureType = (typeof packageFeatureType)[number];
|
|
147
|
+
/**
|
|
148
|
+
* Known fields in Backstage package.json files.
|
|
293
149
|
*
|
|
294
150
|
* @public
|
|
295
151
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
152
|
+
interface BackstagePackageJson {
|
|
153
|
+
name: string;
|
|
154
|
+
version: string;
|
|
155
|
+
private?: boolean;
|
|
156
|
+
main?: string;
|
|
157
|
+
module?: string;
|
|
158
|
+
types?: string;
|
|
159
|
+
scripts?: {
|
|
160
|
+
[key: string]: string;
|
|
161
|
+
};
|
|
162
|
+
bundled?: boolean;
|
|
163
|
+
type?: 'module' | 'commonjs';
|
|
164
|
+
backstage?: {
|
|
165
|
+
role?: PackageRole;
|
|
166
|
+
moved?: string;
|
|
167
|
+
/**
|
|
168
|
+
* If set to `true`, the package will be treated as an internal package
|
|
169
|
+
* where any imports will be inlined into the consuming package.
|
|
170
|
+
*
|
|
171
|
+
* When set to `true`, the top-level `private` field must be set to `true`
|
|
172
|
+
* as well.
|
|
173
|
+
*/
|
|
174
|
+
inline?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The ID of the plugin if this is a plugin package. Must always be set for plugin and module packages, and may be set for library packages. A `null` value means that the package is explicitly not a plugin package.
|
|
177
|
+
*/
|
|
178
|
+
pluginId?: string | null;
|
|
179
|
+
/**
|
|
180
|
+
* The parent plugin package of a module. Must always and only be set for module packages.
|
|
181
|
+
*/
|
|
182
|
+
pluginPackage?: string;
|
|
183
|
+
/**
|
|
184
|
+
* All packages that are part of the plugin. Must always and only be set for plugin packages and plugin library packages.
|
|
185
|
+
*/
|
|
186
|
+
pluginPackages?: string[];
|
|
187
|
+
/**
|
|
188
|
+
* Module packages that should be installed alongside this plugin for cross-plugin integrations.
|
|
189
|
+
* If the peer module's target plugin is present, you should have the peer module installed.
|
|
190
|
+
*/
|
|
191
|
+
peerModules?: string[];
|
|
192
|
+
/**
|
|
193
|
+
* The feature types exported from the package, indexed by path.
|
|
194
|
+
*/
|
|
195
|
+
features?: Record<string, BackstagePackageFeatureType>;
|
|
196
|
+
};
|
|
197
|
+
exports?: JsonValue;
|
|
198
|
+
typesVersions?: Record<string, Record<string, string[]>>;
|
|
199
|
+
files?: string[];
|
|
200
|
+
publishConfig?: {
|
|
201
|
+
access?: 'public' | 'restricted';
|
|
202
|
+
directory?: string;
|
|
203
|
+
registry?: string;
|
|
204
|
+
};
|
|
205
|
+
repository?: string | {
|
|
206
|
+
type: string;
|
|
207
|
+
url: string;
|
|
208
|
+
directory: string;
|
|
209
|
+
};
|
|
210
|
+
dependencies?: {
|
|
211
|
+
[key: string]: string;
|
|
212
|
+
};
|
|
213
|
+
peerDependencies?: {
|
|
214
|
+
[key: string]: string;
|
|
215
|
+
};
|
|
216
|
+
devDependencies?: {
|
|
217
|
+
[key: string]: string;
|
|
218
|
+
};
|
|
219
|
+
optionalDependencies?: {
|
|
220
|
+
[key: string]: string;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
298
223
|
/**
|
|
299
|
-
*
|
|
224
|
+
* A local Backstage monorepo package
|
|
300
225
|
*
|
|
301
226
|
* @public
|
|
302
227
|
*/
|
|
303
|
-
type
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* A function that will be called within each worker thread at startup,
|
|
308
|
-
* which should return the worker function that will be called for each item.
|
|
309
|
-
*
|
|
310
|
-
* This function must be defined as an arrow function or using the
|
|
311
|
-
* function keyword, and must be entirely self contained, not referencing
|
|
312
|
-
* any variables outside of its scope. This is because the function source
|
|
313
|
-
* is stringified and evaluated in the worker thread.
|
|
314
|
-
*
|
|
315
|
-
* To pass data to the worker, use the `context` option and `items`, but
|
|
316
|
-
* note that they are both copied by value into the worker thread, except for
|
|
317
|
-
* types that are explicitly shareable across threads, such as `SharedArrayBuffer`.
|
|
318
|
-
*/
|
|
319
|
-
workerFactory: (context: TContext) => ((item: TItem) => Promise<TResult>) | Promise<(item: TItem) => Promise<TResult>>;
|
|
320
|
-
/** Context data supplied to each worker factory */
|
|
321
|
-
context?: TContext;
|
|
228
|
+
type BackstagePackage = {
|
|
229
|
+
dir: string;
|
|
230
|
+
packageJson: BackstagePackageJson;
|
|
322
231
|
};
|
|
323
232
|
/**
|
|
324
|
-
*
|
|
325
|
-
* Each thread processes one item at a time from the provided `options.items`.
|
|
233
|
+
* A local package in the monorepo package graph.
|
|
326
234
|
*
|
|
327
235
|
* @public
|
|
328
236
|
*/
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
237
|
+
type PackageGraphNode = {
|
|
238
|
+
/** The name of the package */
|
|
239
|
+
name: string;
|
|
240
|
+
/** The directory of the package */
|
|
241
|
+
dir: string;
|
|
242
|
+
/** The package data of the package itself */
|
|
243
|
+
packageJson: BackstagePackageJson;
|
|
244
|
+
/** All direct local dependencies of the package */
|
|
245
|
+
allLocalDependencies: Map<string, PackageGraphNode>;
|
|
246
|
+
/** All direct local dependencies that will be present in the published package */
|
|
247
|
+
publishedLocalDependencies: Map<string, PackageGraphNode>;
|
|
248
|
+
/** Local dependencies */
|
|
249
|
+
localDependencies: Map<string, PackageGraphNode>;
|
|
250
|
+
/** Local devDependencies */
|
|
251
|
+
localDevDependencies: Map<string, PackageGraphNode>;
|
|
252
|
+
/** Local optionalDependencies */
|
|
253
|
+
localOptionalDependencies: Map<string, PackageGraphNode>;
|
|
254
|
+
/** All direct incoming local dependencies of the package */
|
|
255
|
+
allLocalDependents: Map<string, PackageGraphNode>;
|
|
256
|
+
/** All direct incoming local dependencies that will be present in the published package */
|
|
257
|
+
publishedLocalDependents: Map<string, PackageGraphNode>;
|
|
258
|
+
/** Incoming local dependencies */
|
|
259
|
+
localDependents: Map<string, PackageGraphNode>;
|
|
260
|
+
/** Incoming local devDependencies */
|
|
261
|
+
localDevDependents: Map<string, PackageGraphNode>;
|
|
262
|
+
/** Incoming local optionalDependencies */
|
|
263
|
+
localOptionalDependents: Map<string, PackageGraphNode>;
|
|
264
|
+
};
|
|
333
265
|
/**
|
|
334
|
-
*
|
|
266
|
+
* Represents a local Backstage monorepo package graph.
|
|
335
267
|
*
|
|
336
268
|
* @public
|
|
337
269
|
*/
|
|
338
|
-
declare class
|
|
270
|
+
declare class PackageGraph extends Map<string, PackageGraphNode> {
|
|
339
271
|
/**
|
|
340
|
-
*
|
|
341
|
-
* of the provided `ref` and HEAD, as well as all files that are not tracked by git.
|
|
272
|
+
* Lists all local packages in a monorepo.
|
|
342
273
|
*/
|
|
343
|
-
static
|
|
274
|
+
static listTargetPackages(): Promise<BackstagePackage[]>;
|
|
344
275
|
/**
|
|
345
|
-
*
|
|
276
|
+
* Creates a package graph from a list of local packages.
|
|
346
277
|
*/
|
|
347
|
-
static
|
|
278
|
+
static fromPackages(packages: Package[]): PackageGraph;
|
|
279
|
+
/**
|
|
280
|
+
* Traverses the package graph and collects a set of package names.
|
|
281
|
+
*
|
|
282
|
+
* The traversal starts at the provided list names, and continues
|
|
283
|
+
* throughout all the names returned by the `collectFn`, which is
|
|
284
|
+
* called once for each seen package.
|
|
285
|
+
*/
|
|
286
|
+
collectPackageNames(startingPackageNames: string[], collectFn: (pkg: PackageGraphNode) => Iterable<string> | undefined): Set<string>;
|
|
287
|
+
/**
|
|
288
|
+
* Lists all packages that have changed since a given git ref.
|
|
289
|
+
*
|
|
290
|
+
* @remarks
|
|
291
|
+
*
|
|
292
|
+
* If the `analyzeLockfile` option is set to true, the change detection will
|
|
293
|
+
* also consider changes to the dependency management lockfile.
|
|
294
|
+
*/
|
|
295
|
+
listChangedPackages(options: {
|
|
296
|
+
ref: string;
|
|
297
|
+
analyzeLockfile?: boolean;
|
|
298
|
+
}): Promise<PackageGraphNode[]>;
|
|
348
299
|
}
|
|
349
300
|
|
|
350
301
|
/**
|
|
351
|
-
*
|
|
302
|
+
* A single entry in a {@link Lockfile}.
|
|
352
303
|
*
|
|
353
304
|
* @public
|
|
354
305
|
*/
|
|
355
|
-
|
|
306
|
+
type LockfileQueryEntry = {
|
|
307
|
+
range: string;
|
|
308
|
+
version: string;
|
|
309
|
+
dataKey: string;
|
|
310
|
+
};
|
|
356
311
|
/**
|
|
357
|
-
*
|
|
312
|
+
* An entry for a single difference between two {@link Lockfile}s.
|
|
358
313
|
*
|
|
359
314
|
* @public
|
|
360
315
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
316
|
+
type LockfileDiffEntry = {
|
|
317
|
+
name: string;
|
|
318
|
+
range: string;
|
|
319
|
+
};
|
|
363
320
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
* Uses a simple presence check on the `workspaces` field. Empty or invalid
|
|
367
|
-
* workspace config is treated as a monorepo; we do not validate patterns.
|
|
321
|
+
* Represents the difference between two {@link Lockfile}s.
|
|
368
322
|
*
|
|
369
323
|
* @public
|
|
370
324
|
*/
|
|
371
|
-
|
|
372
|
-
|
|
325
|
+
type LockfileDiff = {
|
|
326
|
+
added: LockfileDiffEntry[];
|
|
327
|
+
changed: LockfileDiffEntry[];
|
|
328
|
+
removed: LockfileDiffEntry[];
|
|
329
|
+
};
|
|
373
330
|
/**
|
|
374
|
-
*
|
|
331
|
+
* Represents a package manager lockfile.
|
|
375
332
|
*
|
|
376
333
|
* @public
|
|
377
334
|
*/
|
|
378
|
-
|
|
335
|
+
declare class Lockfile {
|
|
336
|
+
/**
|
|
337
|
+
* Load a {@link Lockfile} from a file path.
|
|
338
|
+
*/
|
|
339
|
+
static load(path: string): Promise<Lockfile>;
|
|
340
|
+
/**
|
|
341
|
+
* Parse lockfile contents into a {@link Lockfile}.
|
|
342
|
+
*
|
|
343
|
+
* @public
|
|
344
|
+
*/
|
|
345
|
+
static parse(content: string): Lockfile;
|
|
346
|
+
private readonly packages;
|
|
347
|
+
private readonly data;
|
|
348
|
+
private readonly legacy;
|
|
349
|
+
private constructor();
|
|
350
|
+
/** Returns the name of all packages available in the lockfile */
|
|
351
|
+
get(name: string): LockfileQueryEntry[] | undefined;
|
|
352
|
+
/** Get the entries for a single package in the lockfile */
|
|
353
|
+
keys(): IterableIterator<string>;
|
|
354
|
+
/**
|
|
355
|
+
* Serialize the lockfile back to a string.
|
|
356
|
+
*/
|
|
357
|
+
toString(): string;
|
|
358
|
+
/**
|
|
359
|
+
* Creates a simplified dependency graph from the lockfile data, where each
|
|
360
|
+
* key is a package, and the value is a set of all packages that it depends on
|
|
361
|
+
* across all versions.
|
|
362
|
+
*/
|
|
363
|
+
createSimplifiedDependencyGraph(): Map<string, Set<string>>;
|
|
364
|
+
/**
|
|
365
|
+
* Diff with another lockfile, returning entries that have been
|
|
366
|
+
* added, changed, and removed compared to the other lockfile.
|
|
367
|
+
*/
|
|
368
|
+
diff(otherLockfile: Lockfile): LockfileDiff;
|
|
369
|
+
/**
|
|
370
|
+
* Generates a sha1 hex hash of the dependency graph for a package.
|
|
371
|
+
*/
|
|
372
|
+
getDependencyTreeHash(startName: string): string;
|
|
373
|
+
}
|
|
374
|
+
|
|
379
375
|
/**
|
|
380
|
-
*
|
|
376
|
+
* Information about the package that a package command is being run in,
|
|
377
|
+
* used to decide whether a toggleable command is enabled.
|
|
381
378
|
*
|
|
382
379
|
* @public
|
|
383
380
|
*/
|
|
384
|
-
|
|
381
|
+
interface CliPackageContext {
|
|
382
|
+
/**
|
|
383
|
+
* The absolute path to the package directory, which is the directory of
|
|
384
|
+
* the nearest `package.json` at or above the current working directory.
|
|
385
|
+
*/
|
|
386
|
+
dir: string;
|
|
387
|
+
/**
|
|
388
|
+
* The contents of the package's `package.json`.
|
|
389
|
+
*/
|
|
390
|
+
packageJson: BackstagePackageJson;
|
|
391
|
+
}
|
|
385
392
|
/**
|
|
386
|
-
* The
|
|
393
|
+
* The context provided to a CLI command at the time of execution.
|
|
387
394
|
*
|
|
388
|
-
*
|
|
389
|
-
*/
|
|
390
|
-
type PackageOutputType = 'bundle' | 'types' | 'esm' | 'cjs';
|
|
391
|
-
/**
|
|
392
|
-
* Information about a package role.
|
|
395
|
+
* Contains the parsed arguments and metadata about the command being run.
|
|
393
396
|
*
|
|
394
397
|
* @public
|
|
395
398
|
*/
|
|
396
|
-
interface
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
399
|
+
interface CliCommandContext {
|
|
400
|
+
/**
|
|
401
|
+
* The remaining arguments passed to the command after the command path
|
|
402
|
+
* has been resolved. This includes both positional arguments and flags.
|
|
403
|
+
*
|
|
404
|
+
* For example, running `backstage-cli repo test --verbose src/` would
|
|
405
|
+
* result in `args` being `['--verbose', 'src/']`.
|
|
406
|
+
*/
|
|
407
|
+
args: string[];
|
|
408
|
+
/**
|
|
409
|
+
* Metadata about the command being executed.
|
|
410
|
+
*/
|
|
411
|
+
info: {
|
|
412
|
+
/**
|
|
413
|
+
* The full usage string of the command including the program name,
|
|
414
|
+
* for example `"backstage-cli repo test"`.
|
|
415
|
+
*/
|
|
416
|
+
usage: string;
|
|
417
|
+
/**
|
|
418
|
+
* The name of the command as defined by its path,
|
|
419
|
+
* for example `"repo test"`.
|
|
420
|
+
*/
|
|
421
|
+
name: string;
|
|
422
|
+
};
|
|
400
423
|
}
|
|
401
|
-
|
|
402
424
|
/**
|
|
403
|
-
*
|
|
425
|
+
* A command definition for a Backstage CLI plugin.
|
|
426
|
+
*
|
|
427
|
+
* Each command is identified by a `path` that determines its position in
|
|
428
|
+
* the command tree. For example, a path of `['repo', 'test']` registers
|
|
429
|
+
* the command as `backstage-cli repo test`.
|
|
430
|
+
*
|
|
431
|
+
* Commands can either provide an `execute` function directly, or use a
|
|
432
|
+
* `loader` for deferred loading of the implementation. The loader pattern
|
|
433
|
+
* is recommended for commands with heavy dependencies, as it avoids
|
|
434
|
+
* loading the implementation until the command is actually invoked.
|
|
404
435
|
*
|
|
405
436
|
* @public
|
|
406
437
|
*/
|
|
407
|
-
|
|
438
|
+
interface CliCommand {
|
|
408
439
|
/**
|
|
409
|
-
*
|
|
440
|
+
* The path segments that define the command's position in the CLI tree.
|
|
441
|
+
* For example, `['repo', 'test']` maps to `backstage-cli repo test`.
|
|
410
442
|
*/
|
|
411
|
-
|
|
443
|
+
path: string[];
|
|
412
444
|
/**
|
|
413
|
-
*
|
|
445
|
+
* A short description of the command, displayed in help output.
|
|
414
446
|
*/
|
|
415
|
-
|
|
447
|
+
description: string;
|
|
416
448
|
/**
|
|
417
|
-
*
|
|
449
|
+
* If `true`, the command is deprecated and will be hidden from help output
|
|
450
|
+
* but can still be invoked.
|
|
418
451
|
*/
|
|
419
|
-
|
|
452
|
+
deprecated?: boolean;
|
|
453
|
+
/**
|
|
454
|
+
* If `true`, the command is experimental and will be hidden from help
|
|
455
|
+
* output but can still be invoked.
|
|
456
|
+
*/
|
|
457
|
+
experimental?: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* The command implementation, either as a direct function or as a loader
|
|
460
|
+
* that returns the implementation as a default export. The loader form
|
|
461
|
+
* is useful for deferring heavy imports until the command is invoked.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* Direct execution:
|
|
465
|
+
* ```
|
|
466
|
+
* execute: async ({ args }) => { ... }
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* Deferred loading:
|
|
471
|
+
* ```
|
|
472
|
+
* execute: { loader: () => import('./my-command') }
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
execute: ((context: CliCommandContext) => Promise<void>) | {
|
|
476
|
+
loader: () => Promise<{
|
|
477
|
+
default: (context: CliCommandContext) => Promise<void>;
|
|
478
|
+
}>;
|
|
479
|
+
};
|
|
420
480
|
}
|
|
421
|
-
|
|
422
481
|
/**
|
|
423
|
-
* A
|
|
424
|
-
*
|
|
482
|
+
* A command that runs in the context of a single package, registered with
|
|
483
|
+
* `addPackageCommand`. It is available as `backstage-cli package <path>`.
|
|
484
|
+
*
|
|
485
|
+
* Several modules may register the same package command as long as at most
|
|
486
|
+
* one of them omits `if`. When the command is invoked, the `if` condition of
|
|
487
|
+
* each registration is evaluated against the package at the current working
|
|
488
|
+
* directory. If exactly one is enabled it is run, and if several are enabled
|
|
489
|
+
* an error is thrown. If none are enabled, the registration without `if` is
|
|
490
|
+
* run as a fallback, and if there is no fallback an error is thrown.
|
|
425
491
|
*
|
|
426
492
|
* @public
|
|
427
493
|
*/
|
|
428
|
-
|
|
494
|
+
interface CliPackageCommand extends Omit<CliCommand, 'path'> {
|
|
495
|
+
/**
|
|
496
|
+
* The path segments of the command, relative to `package`. For example,
|
|
497
|
+
* `['lint']` maps to `backstage-cli package lint`.
|
|
498
|
+
*/
|
|
499
|
+
path: string[];
|
|
500
|
+
/**
|
|
501
|
+
* An optional condition that makes the command toggleable per package.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```
|
|
505
|
+
* if: ({ packageJson }) => Boolean(packageJson.devDependencies?.vitest)
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
if?: (context: CliPackageContext) => boolean | Promise<boolean>;
|
|
509
|
+
}
|
|
429
510
|
/**
|
|
511
|
+
* An opaque representation of a Backstage CLI plugin, created
|
|
512
|
+
* using {@link createCliModule}.
|
|
513
|
+
*
|
|
430
514
|
* @public
|
|
431
515
|
*/
|
|
432
|
-
|
|
516
|
+
interface CliModule {
|
|
517
|
+
readonly $$type: '@backstage/CliModule';
|
|
518
|
+
}
|
|
519
|
+
|
|
433
520
|
/**
|
|
434
|
-
*
|
|
521
|
+
* Creates a new CLI plugin that provides commands to the Backstage CLI.
|
|
522
|
+
*
|
|
523
|
+
* The `init` callback is invoked immediately at creation time and is used
|
|
524
|
+
* to register commands via the provided registry. The commands are then
|
|
525
|
+
* made available to the CLI host once the returned promise resolves.
|
|
526
|
+
*
|
|
527
|
+
* @example
|
|
528
|
+
* ```
|
|
529
|
+
* import { createCliModule } from '@backstage/cli-node';
|
|
530
|
+
* import packageJson from '../package.json';
|
|
531
|
+
*
|
|
532
|
+
* export default createCliModule({
|
|
533
|
+
* packageJson,
|
|
534
|
+
* init: async reg => {
|
|
535
|
+
* reg.addCommand({
|
|
536
|
+
* path: ['repo', 'test'],
|
|
537
|
+
* description: 'Run tests across the repository',
|
|
538
|
+
* execute: { loader: () => import('./commands/test') },
|
|
539
|
+
* });
|
|
540
|
+
* },
|
|
541
|
+
* });
|
|
542
|
+
* ```
|
|
435
543
|
*
|
|
436
544
|
* @public
|
|
437
545
|
*/
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
main?: string;
|
|
443
|
-
module?: string;
|
|
444
|
-
types?: string;
|
|
445
|
-
scripts?: {
|
|
446
|
-
[key: string]: string;
|
|
546
|
+
declare function createCliModule(options: {
|
|
547
|
+
/** The `package.json` contents of the plugin package, used to identify the plugin. */
|
|
548
|
+
packageJson: {
|
|
549
|
+
name: string;
|
|
447
550
|
};
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
|
|
455
|
-
* where any imports will be inlined into the consuming package.
|
|
456
|
-
*
|
|
457
|
-
* When set to `true`, the top-level `private` field must be set to `true`
|
|
458
|
-
* as well.
|
|
459
|
-
*/
|
|
460
|
-
inline?: boolean;
|
|
461
|
-
/**
|
|
462
|
-
* The ID of the plugin if this is a plugin package. Must always be set for plugin and module packages, and may be set for library packages. A `null` value means that the package is explicitly not a plugin package.
|
|
463
|
-
*/
|
|
464
|
-
pluginId?: string | null;
|
|
465
|
-
/**
|
|
466
|
-
* The parent plugin package of a module. Must always and only be set for module packages.
|
|
467
|
-
*/
|
|
468
|
-
pluginPackage?: string;
|
|
469
|
-
/**
|
|
470
|
-
* All packages that are part of the plugin. Must always and only be set for plugin packages and plugin library packages.
|
|
471
|
-
*/
|
|
472
|
-
pluginPackages?: string[];
|
|
473
|
-
/**
|
|
474
|
-
* Module packages that should be installed alongside this plugin for cross-plugin integrations.
|
|
475
|
-
* If the peer module's target plugin is present, you should have the peer module installed.
|
|
476
|
-
*/
|
|
477
|
-
peerModules?: string[];
|
|
551
|
+
/**
|
|
552
|
+
* An initialization callback that registers commands with the CLI.
|
|
553
|
+
* Called immediately when the plugin is created.
|
|
554
|
+
*/
|
|
555
|
+
init: (registry: {
|
|
556
|
+
/** Registers a new command with the CLI. */
|
|
557
|
+
addCommand: (command: CliCommand) => void;
|
|
478
558
|
/**
|
|
479
|
-
*
|
|
559
|
+
* Registers a command under `package`, with an optional `if` condition
|
|
560
|
+
* that enables it only for matching packages.
|
|
480
561
|
*/
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
files?: string[];
|
|
486
|
-
publishConfig?: {
|
|
487
|
-
access?: 'public' | 'restricted';
|
|
488
|
-
directory?: string;
|
|
489
|
-
registry?: string;
|
|
490
|
-
};
|
|
491
|
-
repository?: string | {
|
|
492
|
-
type: string;
|
|
493
|
-
url: string;
|
|
494
|
-
directory: string;
|
|
495
|
-
};
|
|
496
|
-
dependencies?: {
|
|
497
|
-
[key: string]: string;
|
|
498
|
-
};
|
|
499
|
-
peerDependencies?: {
|
|
500
|
-
[key: string]: string;
|
|
501
|
-
};
|
|
502
|
-
devDependencies?: {
|
|
503
|
-
[key: string]: string;
|
|
504
|
-
};
|
|
505
|
-
optionalDependencies?: {
|
|
506
|
-
[key: string]: string;
|
|
507
|
-
};
|
|
508
|
-
}
|
|
562
|
+
addPackageCommand: (command: CliPackageCommand) => void;
|
|
563
|
+
}) => Promise<void>;
|
|
564
|
+
}): CliModule;
|
|
565
|
+
|
|
509
566
|
/**
|
|
510
|
-
*
|
|
567
|
+
* Runs a collection of CLI modules as an executable program.
|
|
568
|
+
*
|
|
569
|
+
* This is intended for creating custom CLI packages from a fixed set of
|
|
570
|
+
* directly imported modules. Module discovery and override behavior are left
|
|
571
|
+
* to the caller.
|
|
572
|
+
*
|
|
573
|
+
* Multiple modules may provide the same `package` command if all but at most
|
|
574
|
+
* one of them declare `if`. The variant to run is selected at invocation
|
|
575
|
+
* time based on the package at the current working directory, see
|
|
576
|
+
* {@link CliPackageCommand.if}.
|
|
577
|
+
*
|
|
578
|
+
* Invoking the program or a command group without a subcommand displays
|
|
579
|
+
* help for that level and completes successfully. Command groups and commands
|
|
580
|
+
* are listed separately in alphabetical order. Group previews fit the terminal width
|
|
581
|
+
* (80 columns when unavailable), expanding nested groups breadth-first when space
|
|
582
|
+
* permits. Unexpanded groups have a trailing slash; truncated previews end in an ellipsis.
|
|
583
|
+
*
|
|
584
|
+
* When a command completes without throwing, the process exits with
|
|
585
|
+
* `process.exitCode`, or `0` if it is not set. Commands can set
|
|
586
|
+
* `process.exitCode` to report a failure, such as invalid input, without
|
|
587
|
+
* throwing an error.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```ts
|
|
591
|
+
* import { runCli } from '@backstage/cli-node';
|
|
592
|
+
* import buildModule from '@backstage/cli-module-build';
|
|
593
|
+
* import testModule from '@backstage/cli-module-test-jest';
|
|
594
|
+
* import packageJson from '../package.json';
|
|
595
|
+
*
|
|
596
|
+
* runCli({
|
|
597
|
+
* modules: [buildModule, testModule],
|
|
598
|
+
* name: packageJson.name,
|
|
599
|
+
* version: packageJson.version,
|
|
600
|
+
* });
|
|
601
|
+
* ```
|
|
511
602
|
*
|
|
512
603
|
* @public
|
|
513
604
|
*/
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
605
|
+
declare function runCli(options: {
|
|
606
|
+
/** The CLI modules whose commands are included in the program. */
|
|
607
|
+
modules: ReadonlyArray<CliModule>;
|
|
608
|
+
/** The program name shown in help output and usage strings. */
|
|
609
|
+
name: string;
|
|
610
|
+
/** The version string shown when `--version` is passed. */
|
|
611
|
+
version?: string;
|
|
612
|
+
}): Promise<void>;
|
|
613
|
+
|
|
518
614
|
/**
|
|
519
|
-
*
|
|
615
|
+
* Runs a CLI module as a standalone program.
|
|
520
616
|
*
|
|
617
|
+
* @deprecated Use {@link runCli} with a single entry in the `modules` array instead.
|
|
521
618
|
* @public
|
|
522
619
|
*/
|
|
523
|
-
|
|
524
|
-
/** The
|
|
620
|
+
declare function runCliModule(options: {
|
|
621
|
+
/** The CLI module to run. */
|
|
622
|
+
module: CliModule;
|
|
623
|
+
/** The program name shown in help output and usage strings. */
|
|
525
624
|
name: string;
|
|
526
|
-
/** The
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
/** All direct local dependencies of the package */
|
|
531
|
-
allLocalDependencies: Map<string, PackageGraphNode>;
|
|
532
|
-
/** All direct local dependencies that will be present in the published package */
|
|
533
|
-
publishedLocalDependencies: Map<string, PackageGraphNode>;
|
|
534
|
-
/** Local dependencies */
|
|
535
|
-
localDependencies: Map<string, PackageGraphNode>;
|
|
536
|
-
/** Local devDependencies */
|
|
537
|
-
localDevDependencies: Map<string, PackageGraphNode>;
|
|
538
|
-
/** Local optionalDependencies */
|
|
539
|
-
localOptionalDependencies: Map<string, PackageGraphNode>;
|
|
540
|
-
/** All direct incoming local dependencies of the package */
|
|
541
|
-
allLocalDependents: Map<string, PackageGraphNode>;
|
|
542
|
-
/** All direct incoming local dependencies that will be present in the published package */
|
|
543
|
-
publishedLocalDependents: Map<string, PackageGraphNode>;
|
|
544
|
-
/** Incoming local dependencies */
|
|
545
|
-
localDependents: Map<string, PackageGraphNode>;
|
|
546
|
-
/** Incoming local devDependencies */
|
|
547
|
-
localDevDependents: Map<string, PackageGraphNode>;
|
|
548
|
-
/** Incoming local optionalDependencies */
|
|
549
|
-
localOptionalDependents: Map<string, PackageGraphNode>;
|
|
550
|
-
};
|
|
625
|
+
/** The version string shown when `--version` is passed. */
|
|
626
|
+
version?: string;
|
|
627
|
+
}): Promise<void>;
|
|
628
|
+
|
|
551
629
|
/**
|
|
552
|
-
*
|
|
630
|
+
* Options for {@link runConcurrentTasks}.
|
|
553
631
|
*
|
|
554
632
|
* @public
|
|
555
633
|
*/
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Lists all local packages in a monorepo.
|
|
559
|
-
*/
|
|
560
|
-
static listTargetPackages(): Promise<BackstagePackage[]>;
|
|
561
|
-
/**
|
|
562
|
-
* Creates a package graph from a list of local packages.
|
|
563
|
-
*/
|
|
564
|
-
static fromPackages(packages: Package[]): PackageGraph;
|
|
565
|
-
/**
|
|
566
|
-
* Traverses the package graph and collects a set of package names.
|
|
567
|
-
*
|
|
568
|
-
* The traversal starts at the provided list names, and continues
|
|
569
|
-
* throughout all the names returned by the `collectFn`, which is
|
|
570
|
-
* called once for each seen package.
|
|
571
|
-
*/
|
|
572
|
-
collectPackageNames(startingPackageNames: string[], collectFn: (pkg: PackageGraphNode) => Iterable<string> | undefined): Set<string>;
|
|
634
|
+
type ConcurrentTasksOptions<TItem> = {
|
|
573
635
|
/**
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* @remarks
|
|
636
|
+
* Decides the number of concurrent workers by multiplying
|
|
637
|
+
* this with the configured concurrency.
|
|
577
638
|
*
|
|
578
|
-
*
|
|
579
|
-
* also consider changes to the dependency management lockfile.
|
|
639
|
+
* Defaults to 1.
|
|
580
640
|
*/
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
641
|
+
concurrencyFactor?: number;
|
|
642
|
+
items: Iterable<TItem>;
|
|
643
|
+
worker: (item: TItem) => Promise<void>;
|
|
644
|
+
};
|
|
587
645
|
/**
|
|
588
|
-
*
|
|
646
|
+
* Runs items through a worker function concurrently across multiple async workers.
|
|
589
647
|
*
|
|
590
648
|
* @public
|
|
591
649
|
*/
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
version: string;
|
|
595
|
-
dataKey: string;
|
|
596
|
-
};
|
|
650
|
+
declare function runConcurrentTasks<TItem>(options: ConcurrentTasksOptions<TItem>): Promise<void>;
|
|
651
|
+
|
|
597
652
|
/**
|
|
598
|
-
*
|
|
653
|
+
* Options for {@link runWorkerQueueThreads}.
|
|
599
654
|
*
|
|
600
655
|
* @public
|
|
601
656
|
*/
|
|
602
|
-
type
|
|
603
|
-
|
|
604
|
-
|
|
657
|
+
type WorkerQueueThreadsOptions<TItem, TResult, TContext> = {
|
|
658
|
+
/** The items to process */
|
|
659
|
+
items: Iterable<TItem>;
|
|
660
|
+
/**
|
|
661
|
+
* A function that will be called within each worker thread at startup,
|
|
662
|
+
* which should return the worker function that will be called for each item.
|
|
663
|
+
*
|
|
664
|
+
* This function must be defined as an arrow function or using the
|
|
665
|
+
* function keyword, and must be entirely self contained, not referencing
|
|
666
|
+
* any variables outside of its scope. This is because the function source
|
|
667
|
+
* is stringified and evaluated in the worker thread.
|
|
668
|
+
*
|
|
669
|
+
* To pass data to the worker, use the `context` option and `items`, but
|
|
670
|
+
* note that they are both copied by value into the worker thread, except for
|
|
671
|
+
* types that are explicitly shareable across threads, such as `SharedArrayBuffer`.
|
|
672
|
+
*/
|
|
673
|
+
workerFactory: (context: TContext) => ((item: TItem) => Promise<TResult>) | Promise<(item: TItem) => Promise<TResult>>;
|
|
674
|
+
/** Context data supplied to each worker factory */
|
|
675
|
+
context?: TContext;
|
|
605
676
|
};
|
|
606
677
|
/**
|
|
607
|
-
*
|
|
678
|
+
* Spawns one or more worker threads using the `worker_threads` module.
|
|
679
|
+
* Each thread processes one item at a time from the provided `options.items`.
|
|
608
680
|
*
|
|
609
681
|
* @public
|
|
610
682
|
*/
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
};
|
|
683
|
+
declare function runWorkerQueueThreads<TItem, TResult, TContext>(options: WorkerQueueThreadsOptions<TItem, TResult, TContext>): Promise<{
|
|
684
|
+
results: TResult[];
|
|
685
|
+
}>;
|
|
686
|
+
|
|
616
687
|
/**
|
|
617
|
-
*
|
|
688
|
+
* Utilities for working with git.
|
|
618
689
|
*
|
|
619
690
|
* @public
|
|
620
691
|
*/
|
|
621
|
-
declare class
|
|
622
|
-
/**
|
|
623
|
-
* Load a {@link Lockfile} from a file path.
|
|
624
|
-
*/
|
|
625
|
-
static load(path: string): Promise<Lockfile>;
|
|
626
|
-
/**
|
|
627
|
-
* Parse lockfile contents into a {@link Lockfile}.
|
|
628
|
-
*
|
|
629
|
-
* @public
|
|
630
|
-
*/
|
|
631
|
-
static parse(content: string): Lockfile;
|
|
632
|
-
private readonly packages;
|
|
633
|
-
private readonly data;
|
|
634
|
-
private readonly legacy;
|
|
635
|
-
private constructor();
|
|
636
|
-
/** Returns the name of all packages available in the lockfile */
|
|
637
|
-
get(name: string): LockfileQueryEntry[] | undefined;
|
|
638
|
-
/** Get the entries for a single package in the lockfile */
|
|
639
|
-
keys(): IterableIterator<string>;
|
|
640
|
-
/**
|
|
641
|
-
* Serialize the lockfile back to a string.
|
|
642
|
-
*/
|
|
643
|
-
toString(): string;
|
|
644
|
-
/**
|
|
645
|
-
* Creates a simplified dependency graph from the lockfile data, where each
|
|
646
|
-
* key is a package, and the value is a set of all packages that it depends on
|
|
647
|
-
* across all versions.
|
|
648
|
-
*/
|
|
649
|
-
createSimplifiedDependencyGraph(): Map<string, Set<string>>;
|
|
692
|
+
declare class GitUtils {
|
|
650
693
|
/**
|
|
651
|
-
*
|
|
652
|
-
*
|
|
694
|
+
* Returns a sorted list of all files that have changed since the merge base
|
|
695
|
+
* of the provided `ref` and HEAD, as well as all files that are not tracked by git.
|
|
653
696
|
*/
|
|
654
|
-
|
|
697
|
+
static listChangedFiles(ref: string): Promise<string[]>;
|
|
655
698
|
/**
|
|
656
|
-
*
|
|
699
|
+
* Returns the contents of a file at a specific ref.
|
|
657
700
|
*/
|
|
658
|
-
|
|
701
|
+
static readFileAtRef(path: string, ref: string): Promise<string>;
|
|
659
702
|
}
|
|
660
703
|
|
|
704
|
+
/**
|
|
705
|
+
* Parses repeatable `key=value` CLI inputs into an object.
|
|
706
|
+
*
|
|
707
|
+
* @public
|
|
708
|
+
*/
|
|
709
|
+
declare function parseKeyValuePairs(pairs: string[] | undefined): Record<string, unknown> | undefined;
|
|
710
|
+
/**
|
|
711
|
+
* Parses a comma-separated CLI input into a list of non-empty strings.
|
|
712
|
+
*
|
|
713
|
+
* @public
|
|
714
|
+
*/
|
|
715
|
+
declare function parseCommaSeparatedList(value: string | undefined): string[] | undefined;
|
|
716
|
+
|
|
661
717
|
/**
|
|
662
718
|
* Detects whether the Backstage Yarn plugin is installed in the given workspace directory.
|
|
663
719
|
*
|
|
@@ -668,4 +724,4 @@ declare class Lockfile {
|
|
|
668
724
|
declare function hasBackstageYarnPlugin(workspaceDir?: string): Promise<boolean>;
|
|
669
725
|
|
|
670
726
|
export { CliAuth, GitUtils, Lockfile, PackageGraph, PackageRoles, SuccessCache, createCliModule, hasBackstageYarnPlugin, isMonoRepo, packageFeatureType, parseCommaSeparatedList, parseKeyValuePairs, runCli, runCliModule, runConcurrentTasks, runWorkerQueueThreads };
|
|
671
|
-
export type { BackstagePackage, BackstagePackageFeatureType, BackstagePackageJson, CliAuthCreateOptions, CliCommand, CliCommandContext, CliModule, ConcurrentTasksOptions, LockfileDiff, LockfileDiffEntry, LockfileQueryEntry, PackageGraphNode, PackageOutputType, PackagePlatform, PackageRole, PackageRoleInfo, WorkerQueueThreadsOptions };
|
|
727
|
+
export type { BackstagePackage, BackstagePackageFeatureType, BackstagePackageJson, CliAuthCreateOptions, CliCommand, CliCommandContext, CliModule, CliPackageCommand, CliPackageContext, ConcurrentTasksOptions, LockfileDiff, LockfileDiffEntry, LockfileQueryEntry, PackageGraphNode, PackageOutputType, PackagePlatform, PackageRole, PackageRoleInfo, WorkerQueueThreadsOptions };
|