Skip to content

Commit 137ee98

Browse files
committed
Merge remote-tracking branch 'remotes/origin/main' into octogonz/heft-updated-schemas
2 parents ec8445b + 4664a49 commit 137ee98

File tree

146 files changed

+1495
-459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+1495
-459
lines changed

apps/api-documenter/CHANGELOG.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
{
22
"name": "@microsoft/api-documenter",
33
"entries": [
4+
{
5+
"version": "7.22.13",
6+
"tag": "@microsoft/api-documenter_v7.22.13",
7+
"date": "Thu, 08 Jun 2023 15:21:17 GMT",
8+
"comments": {
9+
"dependency": [
10+
{
11+
"comment": "Updating dependency \"@rushstack/heft\" to `0.52.2`"
12+
},
13+
{
14+
"comment": "Updating dependency \"@rushstack/heft-node-rig\" to `2.2.2`"
15+
}
16+
]
17+
}
18+
},
419
{
520
"version": "7.22.12",
621
"tag": "@microsoft/api-documenter_v7.22.12",

apps/api-documenter/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log - @microsoft/api-documenter
22

3-
This log was last generated on Thu, 08 Jun 2023 00:20:02 GMT and should not be manually modified.
3+
This log was last generated on Thu, 08 Jun 2023 15:21:17 GMT and should not be manually modified.
4+
5+
## 7.22.13
6+
Thu, 08 Jun 2023 15:21:17 GMT
7+
8+
_Version update only_
49

510
## 7.22.12
611
Thu, 08 Jun 2023 00:20:02 GMT

apps/api-documenter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/api-documenter",
3-
"version": "7.22.12",
3+
"version": "7.22.13",
44
"description": "Read JSON files from api-extractor, generate documentation pages",
55
"repository": {
66
"type": "git",

apps/heft/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
# (Add your project-specific overrides here)
3131
!/includes/**
3232
!UPGRADING.md
33+
!heft-plugin.json

apps/heft/CHANGELOG.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"name": "@rushstack/heft",
33
"entries": [
4+
{
5+
"version": "0.52.2",
6+
"tag": "@rushstack/heft_v0.52.2",
7+
"date": "Thu, 08 Jun 2023 15:21:17 GMT",
8+
"comments": {
9+
"patch": [
10+
{
11+
"comment": "Provide a useful error message when encountering legacy Heft configurations"
12+
}
13+
]
14+
}
15+
},
416
{
517
"version": "0.52.1",
618
"tag": "@rushstack/heft_v0.52.1",

apps/heft/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log - @rushstack/heft
22

3-
This log was last generated on Thu, 08 Jun 2023 00:20:02 GMT and should not be manually modified.
3+
This log was last generated on Thu, 08 Jun 2023 15:21:17 GMT and should not be manually modified.
4+
5+
## 0.52.2
6+
Thu, 08 Jun 2023 15:21:17 GMT
7+
8+
### Patches
9+
10+
- Provide a useful error message when encountering legacy Heft configurations
411

512
## 0.52.1
613
Thu, 08 Jun 2023 00:20:02 GMT

apps/heft/UPGRADING.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Upgrade notes for @rushstack/heft
22

3+
### Heft 0.53.0
4+
The `taskEvent` configuration option in heft.json has been removed, and use of any `taskEvent`-based functionality is now accomplished by referencing the plugins directly within the `@rushstack/heft` package.
5+
6+
Plugin name mappings for previously-existing task events are:
7+
- `copyFiles` -> `copy-files-plugin`
8+
- `deleteFiles` -> `delete-files-plugin`
9+
- `runScript` -> `run-script-plugin`
10+
- `nodeService` -> `node-service-plugin`
11+
12+
Example diff of a heft.json file that uses the `copyFiles` task event:
13+
```diff
14+
{
15+
"phasesByName": {
16+
"build": {
17+
"tasksbyName": {
18+
"perform-copy": {
19+
- "taskEvent": {
20+
- "eventKind": "copyFiles",
21+
+ "taskPlugin": {
22+
+ "pluginPackage": "@rushstack/heft",
23+
+ "pluginName": "copy-files-plugin",
24+
"options": {
25+
...
26+
}
27+
}
28+
}
29+
}
30+
}
31+
}
32+
}
33+
```
34+
335
### Heft 0.52.0
436

537
The `nodeService` built-in plugin now supports the `--serve` parameter, to be consistent with the `@rushstack/heft-webpack5-plugin` dev server.
@@ -91,13 +123,13 @@ Lifecycle plugins are specified in the top-level `heftPlugins` array. Plugins ca
91123

92124
"heftPlugins": [
93125
{
94-
"packageName": "@rushstack/heft-metrics-reporter",
126+
"pluginPackage": "@rushstack/heft-metrics-reporter",
95127
"options": {
96128
"disableMetrics": true
97129
}
98130
},
99131
{
100-
"packageName": "@rushstack/heft-initialization-plugin",
132+
"pluginPackage": "@rushstack/heft-initialization-plugin",
101133
"pluginName": "my-lifecycle-plugin"
102134
}
103135
]
@@ -118,7 +150,7 @@ The following is an example "heft.json" file defining both a "build" and a "test
118150
// "heftPlugins" can be used alongside "phasesByName"
119151
"heftPlugins": [
120152
{
121-
"packageName": "@rushstack/heft-metrics-reporter"
153+
"pluginPackage": "@rushstack/heft-metrics-reporter"
122154
}
123155
],
124156

@@ -146,8 +178,9 @@ The following is an example "heft.json" file defining both a "build" and a "test
146178
}
147179
},
148180
"copy-assets": {
149-
"taskEvent": {
150-
"eventKind": "copyFiles",
181+
"taskPlugin": {
182+
"pluginPackage": "@rushstack/heft",
183+
"pluginName": "copy-files-plugin",
151184
"options": {
152185
"copyOperations": [
153186
{

apps/heft/heft-plugin.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/heft/heft-plugin.schema.json",
3+
4+
"lifecyclePlugins": [],
5+
6+
"taskPlugins": [
7+
{
8+
"pluginName": "copy-files-plugin",
9+
"entryPoint": "./lib/plugins/CopyFilesPlugin",
10+
"optionsSchema": "./lib/schemas/copy-files-options.schema.json"
11+
},
12+
{
13+
"pluginName": "delete-files-plugin",
14+
"entryPoint": "./lib/plugins/DeleteFilesPlugin",
15+
"optionsSchema": "./lib/schemas/delete-files-options.schema.json"
16+
},
17+
{
18+
"pluginName": "node-service-plugin",
19+
"entryPoint": "./lib/plugins/NodeServicePlugin",
20+
"parameterScope": "node-service",
21+
"parameters": [
22+
{
23+
"longName": "--serve",
24+
"parameterKind": "flag",
25+
"description": "Start a local web server for testing purposes. This parameter is only available when running in watch mode."
26+
}
27+
]
28+
},
29+
{
30+
"pluginName": "run-script-plugin",
31+
"entryPoint": "./lib/plugins/RunScriptPlugin",
32+
"optionsSchema": "./lib/schemas/run-script-options.schema.json"
33+
}
34+
]
35+
}

apps/heft/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rushstack/heft",
3-
"version": "0.52.1",
3+
"version": "0.52.2",
44
"description": "Build all your JavaScript projects the same way: A way that works.",
55
"keywords": [
66
"toolchain",

apps/heft/src/configuration/HeftPluginConfiguration.ts

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -80,41 +80,6 @@ export class HeftPluginConfiguration {
8080
return await heftPluginConfigurationPromise;
8181
}
8282

83-
public get lifecyclePluginDefinitions(): ReadonlySet<HeftLifecyclePluginDefinition> {
84-
if (!this._lifecyclePluginDefinitions) {
85-
this._lifecyclePluginDefinitions = new Set();
86-
for (const lifecyclePluginDefinitionJson of this._heftPluginConfigurationJson.lifecyclePlugins || []) {
87-
this._lifecyclePluginDefinitions.add(
88-
HeftLifecyclePluginDefinition.loadFromObject({
89-
heftPluginDefinitionJson: lifecyclePluginDefinitionJson,
90-
packageRoot: this.packageRoot,
91-
packageName: this.packageName
92-
})
93-
);
94-
}
95-
}
96-
return this._lifecyclePluginDefinitions;
97-
}
98-
99-
/**
100-
* Task plugin definitions sourced from the heft-plugin.json file.
101-
*/
102-
public get taskPluginDefinitions(): ReadonlySet<HeftTaskPluginDefinition> {
103-
if (!this._taskPluginDefinitions) {
104-
this._taskPluginDefinitions = new Set();
105-
for (const taskPluginDefinitionJson of this._heftPluginConfigurationJson.taskPlugins || []) {
106-
this._taskPluginDefinitions.add(
107-
HeftTaskPluginDefinition.loadFromObject({
108-
heftPluginDefinitionJson: taskPluginDefinitionJson,
109-
packageRoot: this.packageRoot,
110-
packageName: this.packageName
111-
})
112-
);
113-
}
114-
}
115-
return this._taskPluginDefinitions;
116-
}
117-
11883
/**
11984
* Returns a loaded plugin definition for the provided specifier. Specifiers are normally obtained from the
12085
* heft.json file.
@@ -123,10 +88,10 @@ export class HeftPluginConfiguration {
12388
pluginSpecifier: IHeftConfigurationJsonPluginSpecifier
12489
): HeftPluginDefinitionBase {
12590
if (!pluginSpecifier.pluginName) {
126-
const pluginDefinitions: HeftPluginDefinitionBase[] = [
127-
...this.lifecyclePluginDefinitions,
128-
...this.taskPluginDefinitions
129-
];
91+
const pluginDefinitions: HeftPluginDefinitionBase[] = ([] as HeftPluginDefinitionBase[]).concat(
92+
Array.from(this._getLifecyclePluginDefinitions()),
93+
Array.from(this._getTaskPluginDefinitions())
94+
);
13095
// Make an attempt at resolving the plugin without the name by looking for the first plugin
13196
if (pluginDefinitions.length > 1) {
13297
throw new Error(
@@ -150,6 +115,24 @@ export class HeftPluginConfiguration {
150115
}
151116
}
152117

118+
/**
119+
* Returns if the provided plugin definition is a lifecycle plugin definition.
120+
*/
121+
public isLifecyclePluginDefinition(
122+
pluginDefinition: HeftPluginDefinitionBase
123+
): pluginDefinition is HeftLifecyclePluginDefinition {
124+
return this._getLifecyclePluginDefinitions().has(pluginDefinition);
125+
}
126+
127+
/**
128+
* Returns if the provided plugin definition is a task plugin definition.
129+
*/
130+
public isTaskPluginDefinition(
131+
pluginDefinition: HeftPluginDefinitionBase
132+
): pluginDefinition is HeftTaskPluginDefinition {
133+
return this._getTaskPluginDefinitions().has(pluginDefinition);
134+
}
135+
153136
/**
154137
* Returns a loaded lifecycle plugin definition for the provided plugin name. If one can't be found,
155138
* returns undefined.
@@ -159,7 +142,10 @@ export class HeftPluginConfiguration {
159142
): HeftLifecyclePluginDefinition | undefined {
160143
if (!this._lifecyclePluginDefinitionsMap) {
161144
this._lifecyclePluginDefinitionsMap = new Map(
162-
[...this.lifecyclePluginDefinitions].map((d: HeftLifecyclePluginDefinition) => [d.pluginName, d])
145+
Array.from(this._getLifecyclePluginDefinitions()).map((d: HeftLifecyclePluginDefinition) => [
146+
d.pluginName,
147+
d
148+
])
163149
);
164150
}
165151
return this._lifecyclePluginDefinitionsMap.get(lifecyclePluginName);
@@ -172,12 +158,47 @@ export class HeftPluginConfiguration {
172158
public tryGetTaskPluginDefinitionByName(taskPluginName: string): HeftTaskPluginDefinition | undefined {
173159
if (!this._taskPluginDefinitionsMap) {
174160
this._taskPluginDefinitionsMap = new Map(
175-
[...this.taskPluginDefinitions].map((d: HeftTaskPluginDefinition) => [d.pluginName, d])
161+
Array.from(this._getTaskPluginDefinitions()).map((d: HeftTaskPluginDefinition) => [d.pluginName, d])
176162
);
177163
}
178164
return this._taskPluginDefinitionsMap.get(taskPluginName);
179165
}
180166

167+
private _getLifecyclePluginDefinitions(): ReadonlySet<HeftLifecyclePluginDefinition> {
168+
if (!this._lifecyclePluginDefinitions) {
169+
this._lifecyclePluginDefinitions = new Set();
170+
for (const lifecyclePluginDefinitionJson of this._heftPluginConfigurationJson.lifecyclePlugins || []) {
171+
this._lifecyclePluginDefinitions.add(
172+
HeftLifecyclePluginDefinition.loadFromObject({
173+
heftPluginDefinitionJson: lifecyclePluginDefinitionJson,
174+
packageRoot: this.packageRoot,
175+
packageName: this.packageName
176+
})
177+
);
178+
}
179+
}
180+
return this._lifecyclePluginDefinitions;
181+
}
182+
183+
/**
184+
* Task plugin definitions sourced from the heft-plugin.json file.
185+
*/
186+
private _getTaskPluginDefinitions(): ReadonlySet<HeftTaskPluginDefinition> {
187+
if (!this._taskPluginDefinitions) {
188+
this._taskPluginDefinitions = new Set();
189+
for (const taskPluginDefinitionJson of this._heftPluginConfigurationJson.taskPlugins || []) {
190+
this._taskPluginDefinitions.add(
191+
HeftTaskPluginDefinition.loadFromObject({
192+
heftPluginDefinitionJson: taskPluginDefinitionJson,
193+
packageRoot: this.packageRoot,
194+
packageName: this.packageName
195+
})
196+
);
197+
}
198+
}
199+
return this._taskPluginDefinitions;
200+
}
201+
181202
private _validate(heftPluginConfigurationJson: IHeftPluginConfigurationJson, packageName: string): void {
182203
if (
183204
!heftPluginConfigurationJson.lifecyclePlugins?.length &&

apps/heft/src/configuration/HeftPluginDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export abstract class HeftPluginDefinitionBase {
211211
}
212212

213213
// Ensure that plugin names are unique. Main reason for this restriction is to ensure that command-line
214-
// parameter conflicts can be handled/undocumented synonms can be provided in all scenarios
214+
// parameter conflicts can be handled/undocumented synonyms can be provided in all scenarios
215215
const existingPluginPath: string | undefined = HeftPluginDefinitionBase._loadedPluginPathsByName.get(
216216
this.pluginName
217217
);

apps/heft/src/pluginFramework/HeftLifecycle.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { HeftPluginConfiguration } from '../configuration/HeftPluginConfiguratio
88
import { HeftPluginHost } from './HeftPluginHost';
99
import type { InternalHeftSession } from './InternalHeftSession';
1010
import type { IHeftConfigurationJsonPluginSpecifier } from '../utilities/CoreConfigFiles';
11-
import type { HeftLifecyclePluginDefinition } from '../configuration/HeftPluginDefinition';
11+
import type {
12+
HeftLifecyclePluginDefinition,
13+
HeftPluginDefinitionBase
14+
} from '../configuration/HeftPluginDefinition';
1215
import type { IHeftLifecyclePlugin, IHeftPlugin } from './IHeftPlugin';
1316
import {
1417
HeftLifecycleSession,
@@ -144,11 +147,12 @@ export class HeftLifecycle extends HeftPluginHost {
144147
let pluginConfigurationIndex: number = 0;
145148
for (const pluginSpecifier of this._lifecyclePluginSpecifiers) {
146149
const pluginConfiguration: HeftPluginConfiguration = pluginConfigurations[pluginConfigurationIndex++];
147-
const pluginDefinition: HeftLifecyclePluginDefinition =
150+
const pluginDefinition: HeftPluginDefinitionBase =
148151
pluginConfiguration.getPluginDefinitionBySpecifier(pluginSpecifier);
149152

150153
// Ensure the plugin is a lifecycle plugin
151-
if (!pluginConfiguration.lifecyclePluginDefinitions.has(pluginDefinition)) {
154+
const isLifecyclePlugin: boolean = pluginConfiguration.isLifecyclePluginDefinition(pluginDefinition);
155+
if (!isLifecyclePlugin) {
152156
throw new Error(
153157
`Plugin ${JSON.stringify(pluginDefinition.pluginName)} from package ` +
154158
`${JSON.stringify(pluginSpecifier.pluginPackage)} is not a lifecycle plugin.`

0 commit comments

Comments
 (0)