Use repo-toolbox from the main rushstack repo
This commit is contained in:
Родитель
1a94e40956
Коммит
01076f516f
|
@ -14,4 +14,5 @@ jobs:
|
|||
|
||||
steps:
|
||||
- checkout: self
|
||||
path: rushstack-legacy
|
||||
- template: templates/build.yaml
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
resources:
|
||||
repositories:
|
||||
- repository: RushstackMainRepo
|
||||
type: github
|
||||
name: Microsoft/rushstack
|
||||
endpoint: 'GitHub (Rushbot)'
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
variables:
|
||||
|
@ -6,6 +13,7 @@ variables:
|
|||
steps:
|
||||
- checkout: self
|
||||
persistCredentials: true
|
||||
path: rushstack-legacy
|
||||
- template: templates/build.yaml
|
||||
- template: templates/publish.yaml
|
||||
parameters:
|
||||
|
|
|
@ -6,15 +6,20 @@ steps:
|
|||
checkLatest: true
|
||||
- script: 'git config --local user.email rushbot@users.noreply.github.com'
|
||||
displayName: 'git config email'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
- script: 'git config --local user.name Rushbot'
|
||||
displayName: 'git config name'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
- script: 'node common/scripts/install-run-rush.js change --verify'
|
||||
displayName: 'Verify Change Logs'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
- script: 'node common/scripts/install-run-rush.js install'
|
||||
displayName: 'Rush Install'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
- script: 'node common/scripts/install-run-rush.js rebuild --verbose --production'
|
||||
displayName: 'Rush Rebuild'
|
||||
env:
|
||||
# Prevent time-based browserslist update warning
|
||||
# See https://github.com/microsoft/rushstack/issues/2981
|
||||
BROWSERSLIST_IGNORE_OLD_DATA: 1
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
|
|
|
@ -4,7 +4,9 @@ parameters:
|
|||
steps:
|
||||
- script: 'node common/scripts/install-run-rush.js version --bump --version-policy ${{ parameters.VersionPolicyName }} --target-branch $(Build.SourceBranchName)'
|
||||
displayName: 'Rush Version (Policy: ${{ parameters.VersionPolicyName }})'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
- script: 'node common/scripts/install-run-rush.js publish --apply --publish --include-all --target-branch $(Build.SourceBranchName) --add-commit-details --set-access-level public'
|
||||
displayName: 'Rush Publish (Policy: ${{ parameters.VersionPolicyName }})'
|
||||
env:
|
||||
NPM_AUTH_TOKEN: $(npmToken)
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
steps:
|
||||
- script: 'node repo-scripts/repo-toolbox/lib/start.js record-versions --out-file $(Build.ArtifactStagingDirectory)/published-versions/published-versions.json'
|
||||
- checkout: RushstackMainRepo
|
||||
path: rushstack
|
||||
- script: 'git config --local user.email rushbot@users.noreply.github.com'
|
||||
displayName: 'git config email'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack'
|
||||
- script: 'git config --local user.name Rushbot'
|
||||
displayName: 'git config name'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack'
|
||||
- script: 'node common/scripts/install-run-rush.js install --to repo-toolbox'
|
||||
displayName: 'Rush Install (rushstack)'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack'
|
||||
- script: 'node common/scripts/install-run-rush.js build --verbose --production --to repo-toolbox'
|
||||
displayName: 'Rush Rebuild (rushstack)'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack'
|
||||
- script: 'node $(Agent.BuildDirectory)/rushstack/repo-scripts/repo-toolbox/lib/start.js record-versions --out-file $(Build.ArtifactStagingDirectory)/published-versions/published-versions.json'
|
||||
displayName: 'Record Published Versions'
|
||||
workingDirectory: '$(Agent.BuildDirectory)/rushstack-legacy'
|
||||
- publish: $(Build.ArtifactStagingDirectory)/published-versions
|
||||
artifact: published-versions
|
||||
displayName: 'Publish Artifact: published-versions'
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,5 +1,5 @@
|
|||
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
|
||||
{
|
||||
"pnpmShrinkwrapHash": "44b9943de56380cc8c5f3739ca54021e7140d8cf",
|
||||
"pnpmShrinkwrapHash": "baa4ab8fc33e7a552971938c5ef495c91f957b96",
|
||||
"preferredVersionsHash": "6a96c5550f3ce50aa19e8d1141c6c5d4176953ff"
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// This is a workaround for https://github.com/eslint/eslint/issues/3458
|
||||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
|
||||
module.exports = {
|
||||
extends: [
|
||||
'@rushstack/eslint-config/profile/node-trusted-tool',
|
||||
'@rushstack/eslint-config/mixins/friendly-locals'
|
||||
],
|
||||
parserOptions: { tsconfigRootDir: __dirname }
|
||||
};
|
|
@ -1 +0,0 @@
|
|||
A set of useful scripts for the repo. Keep this in sync with https://github.com/microsoft/rushstack/tree/master/repo-scripts/repo-toolbox
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
// The "rig.json" file directs tools to look for their config files in an external package.
|
||||
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
|
||||
"rigPackageName": "@rushstack/heft-node-rig"
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"name": "repo-toolbox",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Used to execute various operations specific to this repo",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "heft build --clean",
|
||||
"readme": "node ./lib/start.js readme"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/rush-lib": "5.47.0",
|
||||
"@rushstack/node-core-library": "~3.38.0",
|
||||
"@rushstack/ts-command-line": "~4.7.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rushstack/eslint-config": "~2.3.4",
|
||||
"@rushstack/heft": "0.28.0",
|
||||
"@rushstack/heft-node-rig": "1.0.8",
|
||||
"@types/node": "10.17.13",
|
||||
"eslint": "~7.12.1"
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
@echo off
|
||||
node ./lib/start.js %*
|
|
@ -1,140 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See the @microsoft/rush package's LICENSE file for license information.
|
||||
|
||||
import * as path from 'path';
|
||||
import { StringBuilder, Text, Sort, FileSystem } from '@rushstack/node-core-library';
|
||||
import { RushConfiguration, RushConfigurationProject, LockStepVersionPolicy } from '@microsoft/rush-lib';
|
||||
import { CommandLineAction } from '@rushstack/ts-command-line';
|
||||
|
||||
const GENERATED_PROJECT_SUMMARY_START_COMMENT_TEXT: string = '<!-- GENERATED PROJECT SUMMARY START -->';
|
||||
const GENERATED_PROJECT_SUMMARY_END_COMMENT_TEXT: string = '<!-- GENERATED PROJECT SUMMARY END -->';
|
||||
|
||||
export class ReadmeAction extends CommandLineAction {
|
||||
public constructor() {
|
||||
super({
|
||||
actionName: 'readme',
|
||||
summary: 'Generates README.md project table based on rush.json inventory',
|
||||
documentation: "Use this to update the repo's README.md"
|
||||
});
|
||||
}
|
||||
|
||||
private static _isPublished(project: RushConfigurationProject): boolean {
|
||||
return project.shouldPublish || !!project.versionPolicyName;
|
||||
}
|
||||
|
||||
protected async onExecute(): Promise<void> {
|
||||
// abstract
|
||||
|
||||
const rushConfiguration: RushConfiguration = RushConfiguration.loadFromDefaultLocation();
|
||||
|
||||
const repoReadmePath: string = path.resolve(rushConfiguration.rushJsonFolder, 'README.md');
|
||||
const existingReadme: string = await FileSystem.readFileAsync(repoReadmePath);
|
||||
const generatedProjectSummaryStartIndex: number = existingReadme.indexOf(
|
||||
GENERATED_PROJECT_SUMMARY_START_COMMENT_TEXT
|
||||
);
|
||||
const generatedProjectSummaryEndIndex: number = existingReadme.indexOf(
|
||||
GENERATED_PROJECT_SUMMARY_END_COMMENT_TEXT
|
||||
);
|
||||
|
||||
if (generatedProjectSummaryStartIndex === -1 || generatedProjectSummaryEndIndex === -1) {
|
||||
throw new Error(
|
||||
`Unable to find "${GENERATED_PROJECT_SUMMARY_START_COMMENT_TEXT}" or ` +
|
||||
`"${GENERATED_PROJECT_SUMMARY_END_COMMENT_TEXT}" comment in "${repoReadmePath}"`
|
||||
);
|
||||
}
|
||||
|
||||
const readmePrefix: string = existingReadme.substr(
|
||||
0,
|
||||
generatedProjectSummaryStartIndex + GENERATED_PROJECT_SUMMARY_START_COMMENT_TEXT.length
|
||||
);
|
||||
|
||||
const readmePostfix: string = existingReadme.substr(generatedProjectSummaryEndIndex);
|
||||
|
||||
const builder: StringBuilder = new StringBuilder();
|
||||
const orderedProjects: RushConfigurationProject[] = [...rushConfiguration.projects];
|
||||
Sort.sortBy(orderedProjects, (x) => x.projectRelativeFolder);
|
||||
|
||||
builder.append(readmePrefix);
|
||||
builder.append('\n');
|
||||
builder.append('\n');
|
||||
builder.append('## Published Packages\n\n');
|
||||
builder.append('<!-- the table below was generated using the ./repo-scripts/repo-toolbox script -->\n\n');
|
||||
builder.append('| Folder | Version | Changelog | Package |\n');
|
||||
builder.append('| ------ | ------- | --------- | ------- |\n');
|
||||
for (const project of orderedProjects.filter((x) => ReadmeAction._isPublished(x))) {
|
||||
// Example:
|
||||
//
|
||||
// | [/apps/api-extractor](./apps/api-extractor/)
|
||||
// | [![npm version](https://badge.fury.io/js/%40microsoft%2Fapi-extractor.svg
|
||||
// )](https://badge.fury.io/js/%40microsoft%2Fapi-extractor)
|
||||
// | [changelog](./apps/api-extractor/CHANGELOG.md)
|
||||
// | [@microsoft/api-extractor](https://www.npmjs.com/package/@microsoft/api-extractor)
|
||||
// |
|
||||
|
||||
const scopedName: string = project.packageName; // "@microsoft/api-extractor"
|
||||
const folderPath: string = project.projectRelativeFolder; // "apps/api-extractor"
|
||||
let escapedScopedName: string = scopedName; // "%40microsoft%2Fapi-extractor"
|
||||
escapedScopedName = Text.replaceAll(escapedScopedName, '/', '%2F');
|
||||
escapedScopedName = Text.replaceAll(escapedScopedName, '@', '%40');
|
||||
|
||||
// | [/apps/api-extractor](./apps/api-extractor/)
|
||||
builder.append(`| [/${folderPath}](./${folderPath}/) `);
|
||||
|
||||
// | [![npm version](https://badge.fury.io/js/%40microsoft%2Fapi-extractor.svg
|
||||
// )](https://badge.fury.io/js/%40microsoft%2Fapi-extractor)
|
||||
builder.append(
|
||||
`| [![npm version](https://badge.fury.io/js/${escapedScopedName}.svg)]` +
|
||||
`(https://badge.fury.io/js/${escapedScopedName}) `
|
||||
);
|
||||
|
||||
let hasChangeLog: boolean = true;
|
||||
if (project.versionPolicy instanceof LockStepVersionPolicy) {
|
||||
if (project.versionPolicy.mainProject) {
|
||||
if (project.versionPolicy.mainProject !== project.packageName) {
|
||||
hasChangeLog = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// | [changelog](./apps/api-extractor/CHANGELOG.md)
|
||||
if (hasChangeLog) {
|
||||
builder.append(`| [changelog](./${folderPath}/CHANGELOG.md) `);
|
||||
} else {
|
||||
builder.append(`| `);
|
||||
}
|
||||
|
||||
// | [@microsoft/api-extractor](https://www.npmjs.com/package/@microsoft/api-extractor)
|
||||
builder.append(`| [${scopedName}](https://www.npmjs.com/package/${scopedName}) `);
|
||||
|
||||
builder.append(`|\n`);
|
||||
}
|
||||
|
||||
builder.append('\n\n## Unpublished Local Projects\n\n');
|
||||
builder.append('<!-- the table below was generated using the ./repo-scripts/repo-toolbox script -->\n\n');
|
||||
builder.append('| Folder | Description |\n');
|
||||
builder.append('| ------ | -----------|\n');
|
||||
for (const project of orderedProjects.filter((x) => !ReadmeAction._isPublished(x))) {
|
||||
const folderPath: string = project.projectRelativeFolder; // "apps/api-extractor"
|
||||
|
||||
// | [/apps/api-extractor](./apps/api-extractor/)
|
||||
builder.append(`| [/${folderPath}](./${folderPath}/) `);
|
||||
|
||||
const description: string = (project.packageJson.description || '').replace(/[\n\r|]+/g, '');
|
||||
|
||||
builder.append(`| ${description} `);
|
||||
|
||||
builder.append(`|\n`);
|
||||
}
|
||||
|
||||
builder.append(readmePostfix);
|
||||
|
||||
console.log(`Writing ${repoReadmePath}`);
|
||||
FileSystem.writeFile(repoReadmePath, builder.toString());
|
||||
|
||||
console.log('\nSuccess.');
|
||||
}
|
||||
|
||||
protected onDefineParameters(): void {
|
||||
// abstract
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See the @microsoft/rush package's LICENSE file for license information.
|
||||
|
||||
import * as path from 'path';
|
||||
import { Terminal, ConsoleTerminalProvider, JsonFile } from '@rushstack/node-core-library';
|
||||
import { RushConfiguration } from '@microsoft/rush-lib';
|
||||
import { CommandLineAction, CommandLineStringParameter } from '@rushstack/ts-command-line';
|
||||
|
||||
export class RecordVersionsAction extends CommandLineAction {
|
||||
private _outFilePath!: CommandLineStringParameter;
|
||||
|
||||
public constructor() {
|
||||
super({
|
||||
actionName: 'record-versions',
|
||||
summary: 'Generates a JSON file recording the version numbers of all published packages.',
|
||||
documentation: ''
|
||||
});
|
||||
}
|
||||
|
||||
protected onDefineParameters(): void {
|
||||
this._outFilePath = this.defineStringParameter({
|
||||
parameterLongName: '--out-file',
|
||||
parameterShortName: '-o',
|
||||
argumentName: 'FILE_PATH',
|
||||
description: 'The path to the output file.',
|
||||
required: true
|
||||
});
|
||||
}
|
||||
|
||||
protected async onExecute(): Promise<void> {
|
||||
const terminal: Terminal = new Terminal(new ConsoleTerminalProvider());
|
||||
const rushConfig: RushConfiguration = RushConfiguration.loadFromDefaultLocation({
|
||||
startingFolder: process.cwd()
|
||||
});
|
||||
|
||||
terminal.writeLine(`Found Rush configuration at ${rushConfig.rushJsonFile}`);
|
||||
|
||||
const publishedPackageVersions: Record<string, string> = {};
|
||||
for (const project of rushConfig.projects) {
|
||||
if (project.shouldPublish || project.versionPolicy) {
|
||||
publishedPackageVersions[project.packageName] = project.packageJson.version;
|
||||
}
|
||||
}
|
||||
|
||||
const resolvedOutputPath: string = path.resolve(process.cwd(), this._outFilePath.value!);
|
||||
await JsonFile.saveAsync(publishedPackageVersions, resolvedOutputPath, {
|
||||
ensureFolderExists: true
|
||||
});
|
||||
|
||||
terminal.writeLine(`Wrote file to ${resolvedOutputPath}`);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See the @microsoft/rush package's LICENSE file for license information.
|
||||
|
||||
import { CommandLineParser } from '@rushstack/ts-command-line';
|
||||
|
||||
import { ReadmeAction } from './ReadmeAction';
|
||||
import { RecordVersionsAction } from './RecordVersionsAction';
|
||||
|
||||
export class ToolboxCommandLine extends CommandLineParser {
|
||||
public constructor() {
|
||||
super({
|
||||
toolFilename: 'toolbox',
|
||||
toolDescription: 'Used to execute various operations specific to this repo'
|
||||
});
|
||||
|
||||
this.addAction(new ReadmeAction());
|
||||
this.addAction(new RecordVersionsAction());
|
||||
}
|
||||
|
||||
protected onDefineParameters(): void {
|
||||
// abstract
|
||||
}
|
||||
|
||||
protected onExecute(): Promise<void> {
|
||||
// override
|
||||
return super.onExecute();
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See the @microsoft/rush package's LICENSE file for license information.
|
||||
|
||||
import { ToolboxCommandLine } from './ToolboxCommandLine';
|
||||
|
||||
console.log('repo-toolbox\n');
|
||||
|
||||
const commandLine: ToolboxCommandLine = new ToolboxCommandLine();
|
||||
commandLine.execute().catch(console.error); // CommandLineParser.execute() should never reject the promise
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"extends": "./node_modules/@rushstack/heft-node-rig/profiles/default/tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node"]
|
||||
}
|
||||
}
|
|
@ -605,14 +605,6 @@
|
|||
"shouldPublish": true
|
||||
},
|
||||
|
||||
// "core-build" folder (alphabetical order)
|
||||
{
|
||||
"packageName": "repo-toolbox",
|
||||
"projectFolder": "repo-scripts/repo-toolbox",
|
||||
"reviewCategory": "libraries",
|
||||
"shouldPublish": false
|
||||
},
|
||||
|
||||
// "stack" folder (alphabetical order)
|
||||
{
|
||||
"packageName": "@microsoft/rush-stack-compiler-2.4",
|
||||
|
|
Загрузка…
Ссылка в новой задаче