init
This commit is contained in:
24
node_modules/@rushstack/rig-package/LICENSE
generated
vendored
Normal file
24
node_modules/@rushstack/rig-package/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
@rushstack/rig-package
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
229
node_modules/@rushstack/rig-package/README.md
generated
vendored
Normal file
229
node_modules/@rushstack/rig-package/README.md
generated
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
# @rushstack/rig-package
|
||||
|
||||
The **config/rig.json** file is a system that Node.js build tools can adopt, in order to eliminate
|
||||
duplication of config files when many projects share a common configuration. This is particularly valuable
|
||||
in a setup where hundreds of projects may be built using a small set of reusable recipes.
|
||||
|
||||
## Motivation
|
||||
|
||||
For a concrete example, consider the [API Extractor](https://api-extractor.com/) tool which reads its
|
||||
configuration from **\<projectFolder\>/config/api-extractor.json**. Suppose that we have three separate projects
|
||||
that all share the exact same configuration:
|
||||
|
||||
```
|
||||
project1/package.json
|
||||
project1/config/api-extractor.json
|
||||
project1/config/other-tool2.json
|
||||
project1/config/other-tool3.json
|
||||
project1/src/index.ts
|
||||
|
||||
project2/package.json
|
||||
project2/config/api-extractor.json
|
||||
project2/config/other-tool2.json
|
||||
project2/config/other-tool3.json
|
||||
project2/src/index.ts
|
||||
|
||||
project3/package.json
|
||||
project3/config/api-extractor.json
|
||||
project3/config/other-tool2.json
|
||||
project3/config/other-tool3.json
|
||||
project3/src/index.ts
|
||||
```
|
||||
|
||||
It seems wasteful to copy and paste the **api-extractor.json** file with all those settings. If we later need
|
||||
to tune the configuration, we'd have to find and update each file. For a large organization, there could be
|
||||
hundreds of such projects.
|
||||
|
||||
The `"extends"` setting provides a basic way to centralize the configuration in a "rig package". For this example,
|
||||
we'll call our NPM package **example-rig**:
|
||||
|
||||
```
|
||||
example-rig/package.json
|
||||
example-rig/profile/node-library/config/api-extractor.json
|
||||
example-rig/profile/web-library/config/api-extractor.json
|
||||
|
||||
project1/package.json
|
||||
project1/config/api-extractor.json
|
||||
project1/config/other-tool2.json
|
||||
project1/config/other-tool3.json
|
||||
project1/src/index.ts
|
||||
|
||||
project2/package.json
|
||||
project2/config/api-extractor.json
|
||||
project2/config/other-tool2.json
|
||||
project2/config/other-tool3.json
|
||||
project2/src/index.ts
|
||||
|
||||
project3/package.json
|
||||
project3/config/api-extractor.json
|
||||
project3/config/other-tool2.json
|
||||
project3/config/other-tool3.json
|
||||
project3/src/index.ts
|
||||
```
|
||||
|
||||
To make things interesting, above we've introduced two "profiles":
|
||||
|
||||
- `node-library` is for libraries that target the Node.js runtime
|
||||
- `web-library` is for libraries that target a web browser
|
||||
|
||||
> **NOTE:** The `node-library` and `web-library` names are hypothetical examples. The names and purposes of
|
||||
> rig profiles are user-defined. If you only need one profile, then call it `default`.
|
||||
|
||||
If **project1** and **project2** are Node.js libraries, then their **api-extractor.json** now reduces to this:
|
||||
|
||||
**project1/config/api-extractor.json**
|
||||
|
||||
```js
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"extends": "example-rig/profile/node-library/config/api-extractor.json"
|
||||
}
|
||||
```
|
||||
|
||||
Whereas if **project3** is a web browser library, then it might look like this:
|
||||
|
||||
**project3/config/api-extractor.json**
|
||||
|
||||
```js
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"extends": "example-rig/profile/web-library/config/api-extractor.json"
|
||||
}
|
||||
```
|
||||
|
||||
Using `"extends"` definitely made the config file shorter! But imagine that we have a large monorepo with 100 projects.
|
||||
And each project has 5 config files like **api-extactor.json**. We still have to copy+paste 100 x 5 = 500 config files
|
||||
across all our project folders.
|
||||
|
||||
Can we do better?
|
||||
|
||||
## rig.json eliminates files entirely
|
||||
|
||||
The idea is to replace `config/api-extractor.json` and `config/other-tool2.json` (and any other such files)
|
||||
with a single file `config/rig.json` that delegates everything to the rig package:
|
||||
|
||||
**project3/config/rig.json**
|
||||
|
||||
```js
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
|
||||
/**
|
||||
* (Required) The name of the rig package to inherit from.
|
||||
* It should be an NPM package name with the "-rig" suffix.
|
||||
*/
|
||||
"rigPackageName": "example-rig",
|
||||
|
||||
/**
|
||||
* (Optional) Selects a config profile from the rig package. The name must consist of
|
||||
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
||||
* If omitted, then the "default" profile will be used."
|
||||
*/
|
||||
"rigProfile": "web-library"
|
||||
}
|
||||
```
|
||||
|
||||
Using **rig.json** eliminates the `"extends"` stub files entirely. A tool that implements the **rig.json** system
|
||||
would probe for its config file (`<targetFile>.json`) using the following procedure:
|
||||
|
||||
1. First check for `config/<targetFile>.json` in the project folder; if found, use that file. OTHERWISE...
|
||||
2. Check for `config/rig.json`; if found, then this project is using a rig package. Read the `<rigPackageName>`
|
||||
and `<rigProfile>` settings from that file.
|
||||
3. Use Node.js module resolution to find the `<rigPackageName>` package folder (let's call that `<rigPackageFolder>`)
|
||||
4. Check for `<rigPackageFolder>/profile/<rigProfile>/<targetFile>.json`; if found, use that file. OTHERWISE...
|
||||
5. If the `<targetFile>.json` cannot be found in either of these places, the behavior is left to the tool.
|
||||
For example, it could report an error, or proceed using defaults.
|
||||
|
||||
In cases where we need a project-specific customization, the `"extends"` field is still supported. For example,
|
||||
**project1** can still add a local override like this:
|
||||
|
||||
**project1/config/api-extractor.json**
|
||||
|
||||
```js
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"extends": "example-rig/profile/node-library/config/api-extractor.json",
|
||||
|
||||
// Local override:
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/custom.d.ts",
|
||||
}
|
||||
```
|
||||
|
||||
The result is a much shorter inventory of files:
|
||||
|
||||
```
|
||||
example-rig/package.json
|
||||
|
||||
example-rig/profile/node-library/config/api-extractor.json
|
||||
example-rig/profile/node-library/config/other-tool2.json
|
||||
example-rig/profile/node-library/config/other-tool3.json
|
||||
|
||||
example-rig/profile/web-library/config/api-extractor.json
|
||||
example-rig/profile/web-library/config/other-tool2.json
|
||||
example-rig/profile/web-library/config/other-tool3.json
|
||||
|
||||
project1/package.json
|
||||
project1/config/rig.json
|
||||
project1/config/api-extractor.json <-- local override shown above
|
||||
project1/src/index.ts
|
||||
|
||||
project2/package.json
|
||||
project2/config/rig.json
|
||||
project2/src/index.ts
|
||||
|
||||
project3/package.json
|
||||
project3/config/rig.json
|
||||
project3/src/index.ts
|
||||
```
|
||||
|
||||
## The `@rushstack/rig-package` API
|
||||
|
||||
The `@rushstack/rig-package` library provides an API for loading the **rig.json** file and performing lookups.
|
||||
It is a lightweight NPM package, intended to be easy for tool projects to accept as a dependency. The package
|
||||
also includes the JSON schema file **rig.schema.json**.
|
||||
|
||||
Example usage of the API:
|
||||
|
||||
```ts
|
||||
import { RigConfig } from '@rushstack/rig-package';
|
||||
|
||||
// Probe for the rig.json file and load it if found
|
||||
const rigConfig: RigConfig = RigConfig.loadForProjectFolder({
|
||||
// Specify a project folder (i.e. where its package.json file is located)
|
||||
projectFolderPath: testProjectFolder
|
||||
});
|
||||
|
||||
if (rigConfig.rigFound) {
|
||||
// We found a config/rig.json file
|
||||
//
|
||||
// Prints "/path/to/project3/config/rig.json"
|
||||
console.log('Found rig.json: ' + rigConfig.filePath);
|
||||
|
||||
// Prints "example-rig"
|
||||
console.log('The rig package is: ' + rigConfig.rigPackageName);
|
||||
|
||||
// Resolve the rig package
|
||||
//
|
||||
// Prints "/path/to/project3/node_modules/example-rig/profile/web-library"
|
||||
console.log('Profile folder: ' + rigConfig.getResolvedProfileFolder());
|
||||
|
||||
// Look up a config file. These file paths will be tested:
|
||||
//
|
||||
// /path/to/project3/folder/file.json
|
||||
// /path/to/project3/node_modules/example-rig/profile/web-library/folder/file.json
|
||||
//
|
||||
// The result will be the first path that exists, or undefined if the config file was not found.
|
||||
console.log('Resolved config file: ' + rigConfig.tryResolveConfigFilePath('folder/file.json'));
|
||||
}
|
||||
```
|
||||
|
||||
Note that there are also async variants of the functions that access the filesystem.
|
||||
|
||||
## Links
|
||||
|
||||
- [CHANGELOG.md](
|
||||
https://github.com/microsoft/rushstack/blob/main/libraries/rig-package/CHANGELOG.md) - Find
|
||||
out what's new in the latest version
|
||||
- [API Reference](https://rushstack.io/pages/api/rig-package/)
|
||||
|
||||
`@rushstack/rig-package` is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
250
node_modules/@rushstack/rig-package/dist/rig-package.d.ts
generated
vendored
Normal file
250
node_modules/@rushstack/rig-package/dist/rig-package.d.ts
generated
vendored
Normal file
@ -0,0 +1,250 @@
|
||||
/**
|
||||
* A system for sharing tool configurations between projects without duplicating config files.
|
||||
*
|
||||
* @remarks
|
||||
* The `config/rig.json` file is a system that Node.js build tools can support, in order to eliminate
|
||||
* duplication of config files when many projects share a common configuration. This is particularly valuable
|
||||
* in a setup where hundreds of projects may be built using a small set of reusable recipes.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
/**
|
||||
* Options for {@link RigConfig.loadForProjectFolder}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface ILoadForProjectFolderOptions {
|
||||
/**
|
||||
* The path to the folder of the project to be analyzed. This folder should contain a `package.json` file.
|
||||
*/
|
||||
projectFolderPath: string;
|
||||
/**
|
||||
* If specified, instead of loading the `config/rig.json` from disk, this object will be substituted instead.
|
||||
*/
|
||||
overrideRigJsonObject?: IRigConfigJson;
|
||||
/**
|
||||
* If specified, force a fresh load instead of returning a cached entry, if one existed.
|
||||
*/
|
||||
bypassCache?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main API for loading the `config/rig.json` file format.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface IRigConfig {
|
||||
/**
|
||||
* The project folder path that was passed to {@link RigConfig.loadForProjectFolder},
|
||||
* which maybe an absolute or relative path.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `.`
|
||||
*/
|
||||
readonly projectFolderOriginalPath: string;
|
||||
/**
|
||||
* The absolute path for the project folder path that was passed to {@link RigConfig.loadForProjectFolder}.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `/path/to/your-project`
|
||||
*/
|
||||
readonly projectFolderPath: string;
|
||||
/**
|
||||
* Returns `true` if `config/rig.json` was found, or `false` otherwise.
|
||||
*/
|
||||
readonly rigFound: boolean;
|
||||
/**
|
||||
* The full path to the `rig.json` file that was found, or `""` if none was found.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `/path/to/your-project/config/rig.json`
|
||||
*/
|
||||
readonly filePath: string;
|
||||
/**
|
||||
* The `"rigPackageName"` field from `rig.json`, or `""` if the file was not found.
|
||||
*
|
||||
* @remarks
|
||||
* The name must be a valid NPM package name, and must end with the `-rig` suffix.
|
||||
*
|
||||
* Example: `example-rig`
|
||||
*/
|
||||
readonly rigPackageName: string;
|
||||
/**
|
||||
* The `"rigProfile"` value that was loaded from `rig.json`, or `""` if the file was not found.
|
||||
*
|
||||
* @remarks
|
||||
* The name must consist of lowercase alphanumeric words separated by hyphens, for example `"sample-profile"`.
|
||||
* If the `rig.json` file exists, but the `"rigProfile"` is not specified, then the profile
|
||||
* name will be `"default"`.
|
||||
*
|
||||
* Example: `example-profile`
|
||||
*/
|
||||
readonly rigProfile: string;
|
||||
/**
|
||||
* The relative path to the rig profile specified by `rig.json`, or `""` if the file was not found.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `profiles/example-profile`
|
||||
*/
|
||||
readonly relativeProfileFolderPath: string;
|
||||
/**
|
||||
* Performs Node.js module resolution to locate the rig package folder, then returns the absolute path
|
||||
* of the rig profile folder specified by `rig.json`.
|
||||
*
|
||||
* @remarks
|
||||
* If no `rig.json` file was found, then this method throws an error. The first time this method
|
||||
* is called, the result is cached and will be returned by all subsequent calls.
|
||||
*
|
||||
* Example: `/path/to/your-project/node_modules/example-rig/profiles/example-profile`
|
||||
*/
|
||||
getResolvedProfileFolder(): string;
|
||||
/**
|
||||
* An async variant of {@link IRigConfig.getResolvedProfileFolder}
|
||||
*/
|
||||
getResolvedProfileFolderAsync(): Promise<string>;
|
||||
/**
|
||||
* This lookup first checks for the specified relative path under `projectFolderPath`; if it does
|
||||
* not exist there, then it checks in the resolved rig profile folder. If the file is found,
|
||||
* its absolute path is returned. Otherwise, `undefined` is returned.
|
||||
*
|
||||
* @remarks
|
||||
* For example, suppose the rig profile is:
|
||||
*
|
||||
* `/path/to/your-project/node_modules/example-rig/profiles/example-profile`
|
||||
*
|
||||
* And suppose `configFileRelativePath` is `folder/file.json`. Then the following locations will be checked:
|
||||
*
|
||||
* `/path/to/your-project/folder/file.json`
|
||||
*
|
||||
* `/path/to/your-project/node_modules/example-rig/profiles/example-profile/folder/file.json`
|
||||
*/
|
||||
tryResolveConfigFilePath(configFileRelativePath: string): string | undefined;
|
||||
/**
|
||||
* An async variant of {@link IRigConfig.tryResolveConfigFilePath}
|
||||
*/
|
||||
tryResolveConfigFilePathAsync(configFileRelativePath: string): Promise<string | undefined>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the literal contents of the `config/rig.json` file.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface IRigConfigJson {
|
||||
/**
|
||||
* The name of the rig package to use.
|
||||
*
|
||||
* @remarks
|
||||
* The name must be a valid NPM package name, and must end with the `-rig` suffix.
|
||||
*
|
||||
* Example: `example-rig`
|
||||
*/
|
||||
rigPackageName: string;
|
||||
/**
|
||||
* Specify which rig profile to use from the rig package.
|
||||
*
|
||||
* @remarks
|
||||
* The name must consist of lowercase alphanumeric words separated by hyphens, for example `"sample-profile"`.
|
||||
* If the `"rigProfile"` is not specified, then the profile name `"default"` will be used.
|
||||
*
|
||||
* Example: `example-profile`
|
||||
*/
|
||||
rigProfile?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc IRigConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare class RigConfig implements IRigConfig {
|
||||
private static readonly _packageNameRegExp;
|
||||
private static readonly _rigNameRegExp;
|
||||
private static readonly _profileNameRegExp;
|
||||
/**
|
||||
* Returns the absolute path of the `rig.schema.json` JSON schema file for `config/rig.json`,
|
||||
* which is bundled with this NPM package.
|
||||
*
|
||||
* @remarks
|
||||
* The `RigConfig` class already performs schema validation when loading `rig.json`; however
|
||||
* this schema file may be useful for integration with other validation tools.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static jsonSchemaPath: string;
|
||||
private static _jsonSchemaObject;
|
||||
private static readonly _configCache;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.projectFolderOriginalPath}
|
||||
*/
|
||||
readonly projectFolderOriginalPath: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.projectFolderPath}
|
||||
*/
|
||||
readonly projectFolderPath: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.rigFound}
|
||||
*/
|
||||
readonly rigFound: boolean;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.filePath}
|
||||
*/
|
||||
readonly filePath: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.rigPackageName}
|
||||
*/
|
||||
readonly rigPackageName: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.rigProfile}
|
||||
*/
|
||||
readonly rigProfile: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.relativeProfileFolderPath}
|
||||
*/
|
||||
readonly relativeProfileFolderPath: string;
|
||||
private _resolvedRigPackageFolder;
|
||||
private _resolvedProfileFolder;
|
||||
private constructor();
|
||||
/**
|
||||
* The JSON contents of the {@link RigConfig.jsonSchemaPath} file.
|
||||
*
|
||||
* @remarks
|
||||
* The JSON object will be lazily loaded when this property getter is accessed, and the result
|
||||
* will be cached.
|
||||
* Accessing this property may make a synchronous filesystem call.
|
||||
*/
|
||||
static get jsonSchemaObject(): object;
|
||||
/**
|
||||
* Use this method to load the `config/rig.json` file for a given project.
|
||||
*
|
||||
* @remarks
|
||||
* If the file cannot be found, an empty `RigConfig` object will be returned with {@link RigConfig.rigFound}
|
||||
* equal to `false`.
|
||||
*/
|
||||
static loadForProjectFolder(options: ILoadForProjectFolderOptions): RigConfig;
|
||||
/**
|
||||
* An async variant of {@link RigConfig.loadForProjectFolder}
|
||||
*/
|
||||
static loadForProjectFolderAsync(options: ILoadForProjectFolderOptions): Promise<RigConfig>;
|
||||
private static _handleConfigError;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.getResolvedProfileFolder}
|
||||
*/
|
||||
getResolvedProfileFolder(): string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.getResolvedProfileFolderAsync}
|
||||
*/
|
||||
getResolvedProfileFolderAsync(): Promise<string>;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.tryResolveConfigFilePath}
|
||||
*/
|
||||
tryResolveConfigFilePath(configFileRelativePath: string): string | undefined;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.tryResolveConfigFilePathAsync}
|
||||
*/
|
||||
tryResolveConfigFilePathAsync(configFileRelativePath: string): Promise<string | undefined>;
|
||||
private static _validateSchema;
|
||||
}
|
||||
|
||||
export { }
|
11
node_modules/@rushstack/rig-package/dist/tsdoc-metadata.json
generated
vendored
Normal file
11
node_modules/@rushstack/rig-package/dist/tsdoc-metadata.json
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
||||
// It should be published with your NPM package. It should not be tracked by Git.
|
||||
{
|
||||
"tsdocVersion": "0.12",
|
||||
"toolPackages": [
|
||||
{
|
||||
"packageName": "@microsoft/api-extractor",
|
||||
"packageVersion": "7.37.0"
|
||||
}
|
||||
]
|
||||
}
|
10
node_modules/@rushstack/rig-package/lib/Helpers.d.ts
generated
vendored
Normal file
10
node_modules/@rushstack/rig-package/lib/Helpers.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/// <reference types="node" />
|
||||
import * as fs from 'fs';
|
||||
import nodeResolve from 'resolve';
|
||||
export declare class Helpers {
|
||||
private static _upwardPathSegmentRegex;
|
||||
static nodeResolveAsync(id: string, opts: nodeResolve.AsyncOpts): Promise<string>;
|
||||
static fsExistsAsync(filesystemPath: fs.PathLike): Promise<boolean>;
|
||||
static isDownwardRelative(inputPath: string): boolean;
|
||||
}
|
||||
//# sourceMappingURL=Helpers.d.ts.map
|
1
node_modules/@rushstack/rig-package/lib/Helpers.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/rig-package/lib/Helpers.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../src/Helpers.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,WAAW,MAAM,SAAS,CAAC;AAGlC,qBAAa,OAAO;IAElB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAsC;WAExD,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;WAY1E,aAAa,CAAC,cAAc,EAAE,EAAE,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;WASlE,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAU7D"}
|
71
node_modules/@rushstack/rig-package/lib/Helpers.js
generated
vendored
Normal file
71
node_modules/@rushstack/rig-package/lib/Helpers.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Helpers = void 0;
|
||||
const path = __importStar(require("path"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const resolve_1 = __importDefault(require("resolve"));
|
||||
// These helpers avoid taking dependencies on other NPM packages
|
||||
class Helpers {
|
||||
static async nodeResolveAsync(id, opts) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
(0, resolve_1.default)(id, opts, (error, result) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
else {
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
static async fsExistsAsync(filesystemPath) {
|
||||
return await new Promise((resolve) => {
|
||||
fs.exists(filesystemPath, (exists) => {
|
||||
resolve(exists);
|
||||
});
|
||||
});
|
||||
}
|
||||
// Based on Path.isDownwardRelative() from @rushstack/node-core-library
|
||||
static isDownwardRelative(inputPath) {
|
||||
if (path.isAbsolute(inputPath)) {
|
||||
return false;
|
||||
}
|
||||
// Does it contain ".."
|
||||
if (Helpers._upwardPathSegmentRegex.test(inputPath)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Based on Path.isDownwardRelative() from @rushstack/node-core-library
|
||||
Helpers._upwardPathSegmentRegex = /([\/\\]|^)\.\.([\/\\]|$)/;
|
||||
exports.Helpers = Helpers;
|
||||
//# sourceMappingURL=Helpers.js.map
|
1
node_modules/@rushstack/rig-package/lib/Helpers.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/rig-package/lib/Helpers.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../src/Helpers.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAC7B,uCAAyB;AACzB,sDAAkC;AAElC,gEAAgE;AAChE,MAAa,OAAO;IAIX,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAU,EAAE,IAA2B;QAC1E,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAiC,EAAE,MAA8B,EAAE,EAAE;YAC7F,IAAA,iBAAW,EAAC,EAAE,EAAE,IAAI,EAAE,CAAC,KAAmB,EAAE,MAA0B,EAAE,EAAE;gBACxE,IAAI,KAAK,EAAE;oBACT,MAAM,CAAC,KAAK,CAAC,CAAC;iBACf;qBAAM;oBACL,OAAO,CAAC,MAAO,CAAC,CAAC;iBAClB;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,cAA2B;QAC3D,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAkC,EAAE,EAAE;YAC9D,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,MAAe,EAAE,EAAE;gBAC5C,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uEAAuE;IAChE,MAAM,CAAC,kBAAkB,CAAC,SAAiB;QAChD,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAC9B,OAAO,KAAK,CAAC;SACd;QACD,uBAAuB;QACvB,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YACnD,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AAjCD,uEAAuE;AACxD,+BAAuB,GAAW,0BAA0B,CAAC;AAFjE,0BAAO","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport nodeResolve from 'resolve';\n\n// These helpers avoid taking dependencies on other NPM packages\nexport class Helpers {\n // Based on Path.isDownwardRelative() from @rushstack/node-core-library\n private static _upwardPathSegmentRegex: RegExp = /([\\/\\\\]|^)\\.\\.([\\/\\\\]|$)/;\n\n public static async nodeResolveAsync(id: string, opts: nodeResolve.AsyncOpts): Promise<string> {\n return await new Promise((resolve: (result: string) => void, reject: (error: Error) => void) => {\n nodeResolve(id, opts, (error: Error | null, result: string | undefined) => {\n if (error) {\n reject(error);\n } else {\n resolve(result!);\n }\n });\n });\n }\n\n public static async fsExistsAsync(filesystemPath: fs.PathLike): Promise<boolean> {\n return await new Promise((resolve: (result: boolean) => void) => {\n fs.exists(filesystemPath, (exists: boolean) => {\n resolve(exists);\n });\n });\n }\n\n // Based on Path.isDownwardRelative() from @rushstack/node-core-library\n public static isDownwardRelative(inputPath: string): boolean {\n if (path.isAbsolute(inputPath)) {\n return false;\n }\n // Does it contain \"..\"\n if (Helpers._upwardPathSegmentRegex.test(inputPath)) {\n return false;\n }\n return true;\n }\n}\n"]}
|
235
node_modules/@rushstack/rig-package/lib/RigConfig.d.ts
generated
vendored
Normal file
235
node_modules/@rushstack/rig-package/lib/RigConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
/**
|
||||
* Represents the literal contents of the `config/rig.json` file.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IRigConfigJson {
|
||||
/**
|
||||
* The name of the rig package to use.
|
||||
*
|
||||
* @remarks
|
||||
* The name must be a valid NPM package name, and must end with the `-rig` suffix.
|
||||
*
|
||||
* Example: `example-rig`
|
||||
*/
|
||||
rigPackageName: string;
|
||||
/**
|
||||
* Specify which rig profile to use from the rig package.
|
||||
*
|
||||
* @remarks
|
||||
* The name must consist of lowercase alphanumeric words separated by hyphens, for example `"sample-profile"`.
|
||||
* If the `"rigProfile"` is not specified, then the profile name `"default"` will be used.
|
||||
*
|
||||
* Example: `example-profile`
|
||||
*/
|
||||
rigProfile?: string;
|
||||
}
|
||||
/**
|
||||
* Options for {@link RigConfig.loadForProjectFolder}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ILoadForProjectFolderOptions {
|
||||
/**
|
||||
* The path to the folder of the project to be analyzed. This folder should contain a `package.json` file.
|
||||
*/
|
||||
projectFolderPath: string;
|
||||
/**
|
||||
* If specified, instead of loading the `config/rig.json` from disk, this object will be substituted instead.
|
||||
*/
|
||||
overrideRigJsonObject?: IRigConfigJson;
|
||||
/**
|
||||
* If specified, force a fresh load instead of returning a cached entry, if one existed.
|
||||
*/
|
||||
bypassCache?: boolean;
|
||||
}
|
||||
/**
|
||||
* This is the main API for loading the `config/rig.json` file format.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface IRigConfig {
|
||||
/**
|
||||
* The project folder path that was passed to {@link RigConfig.loadForProjectFolder},
|
||||
* which maybe an absolute or relative path.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `.`
|
||||
*/
|
||||
readonly projectFolderOriginalPath: string;
|
||||
/**
|
||||
* The absolute path for the project folder path that was passed to {@link RigConfig.loadForProjectFolder}.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `/path/to/your-project`
|
||||
*/
|
||||
readonly projectFolderPath: string;
|
||||
/**
|
||||
* Returns `true` if `config/rig.json` was found, or `false` otherwise.
|
||||
*/
|
||||
readonly rigFound: boolean;
|
||||
/**
|
||||
* The full path to the `rig.json` file that was found, or `""` if none was found.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `/path/to/your-project/config/rig.json`
|
||||
*/
|
||||
readonly filePath: string;
|
||||
/**
|
||||
* The `"rigPackageName"` field from `rig.json`, or `""` if the file was not found.
|
||||
*
|
||||
* @remarks
|
||||
* The name must be a valid NPM package name, and must end with the `-rig` suffix.
|
||||
*
|
||||
* Example: `example-rig`
|
||||
*/
|
||||
readonly rigPackageName: string;
|
||||
/**
|
||||
* The `"rigProfile"` value that was loaded from `rig.json`, or `""` if the file was not found.
|
||||
*
|
||||
* @remarks
|
||||
* The name must consist of lowercase alphanumeric words separated by hyphens, for example `"sample-profile"`.
|
||||
* If the `rig.json` file exists, but the `"rigProfile"` is not specified, then the profile
|
||||
* name will be `"default"`.
|
||||
*
|
||||
* Example: `example-profile`
|
||||
*/
|
||||
readonly rigProfile: string;
|
||||
/**
|
||||
* The relative path to the rig profile specified by `rig.json`, or `""` if the file was not found.
|
||||
*
|
||||
* @remarks
|
||||
* Example: `profiles/example-profile`
|
||||
*/
|
||||
readonly relativeProfileFolderPath: string;
|
||||
/**
|
||||
* Performs Node.js module resolution to locate the rig package folder, then returns the absolute path
|
||||
* of the rig profile folder specified by `rig.json`.
|
||||
*
|
||||
* @remarks
|
||||
* If no `rig.json` file was found, then this method throws an error. The first time this method
|
||||
* is called, the result is cached and will be returned by all subsequent calls.
|
||||
*
|
||||
* Example: `/path/to/your-project/node_modules/example-rig/profiles/example-profile`
|
||||
*/
|
||||
getResolvedProfileFolder(): string;
|
||||
/**
|
||||
* An async variant of {@link IRigConfig.getResolvedProfileFolder}
|
||||
*/
|
||||
getResolvedProfileFolderAsync(): Promise<string>;
|
||||
/**
|
||||
* This lookup first checks for the specified relative path under `projectFolderPath`; if it does
|
||||
* not exist there, then it checks in the resolved rig profile folder. If the file is found,
|
||||
* its absolute path is returned. Otherwise, `undefined` is returned.
|
||||
*
|
||||
* @remarks
|
||||
* For example, suppose the rig profile is:
|
||||
*
|
||||
* `/path/to/your-project/node_modules/example-rig/profiles/example-profile`
|
||||
*
|
||||
* And suppose `configFileRelativePath` is `folder/file.json`. Then the following locations will be checked:
|
||||
*
|
||||
* `/path/to/your-project/folder/file.json`
|
||||
*
|
||||
* `/path/to/your-project/node_modules/example-rig/profiles/example-profile/folder/file.json`
|
||||
*/
|
||||
tryResolveConfigFilePath(configFileRelativePath: string): string | undefined;
|
||||
/**
|
||||
* An async variant of {@link IRigConfig.tryResolveConfigFilePath}
|
||||
*/
|
||||
tryResolveConfigFilePathAsync(configFileRelativePath: string): Promise<string | undefined>;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc IRigConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare class RigConfig implements IRigConfig {
|
||||
private static readonly _packageNameRegExp;
|
||||
private static readonly _rigNameRegExp;
|
||||
private static readonly _profileNameRegExp;
|
||||
/**
|
||||
* Returns the absolute path of the `rig.schema.json` JSON schema file for `config/rig.json`,
|
||||
* which is bundled with this NPM package.
|
||||
*
|
||||
* @remarks
|
||||
* The `RigConfig` class already performs schema validation when loading `rig.json`; however
|
||||
* this schema file may be useful for integration with other validation tools.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static jsonSchemaPath: string;
|
||||
private static _jsonSchemaObject;
|
||||
private static readonly _configCache;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.projectFolderOriginalPath}
|
||||
*/
|
||||
readonly projectFolderOriginalPath: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.projectFolderPath}
|
||||
*/
|
||||
readonly projectFolderPath: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.rigFound}
|
||||
*/
|
||||
readonly rigFound: boolean;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.filePath}
|
||||
*/
|
||||
readonly filePath: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.rigPackageName}
|
||||
*/
|
||||
readonly rigPackageName: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.rigProfile}
|
||||
*/
|
||||
readonly rigProfile: string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.relativeProfileFolderPath}
|
||||
*/
|
||||
readonly relativeProfileFolderPath: string;
|
||||
private _resolvedRigPackageFolder;
|
||||
private _resolvedProfileFolder;
|
||||
private constructor();
|
||||
/**
|
||||
* The JSON contents of the {@link RigConfig.jsonSchemaPath} file.
|
||||
*
|
||||
* @remarks
|
||||
* The JSON object will be lazily loaded when this property getter is accessed, and the result
|
||||
* will be cached.
|
||||
* Accessing this property may make a synchronous filesystem call.
|
||||
*/
|
||||
static get jsonSchemaObject(): object;
|
||||
/**
|
||||
* Use this method to load the `config/rig.json` file for a given project.
|
||||
*
|
||||
* @remarks
|
||||
* If the file cannot be found, an empty `RigConfig` object will be returned with {@link RigConfig.rigFound}
|
||||
* equal to `false`.
|
||||
*/
|
||||
static loadForProjectFolder(options: ILoadForProjectFolderOptions): RigConfig;
|
||||
/**
|
||||
* An async variant of {@link RigConfig.loadForProjectFolder}
|
||||
*/
|
||||
static loadForProjectFolderAsync(options: ILoadForProjectFolderOptions): Promise<RigConfig>;
|
||||
private static _handleConfigError;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.getResolvedProfileFolder}
|
||||
*/
|
||||
getResolvedProfileFolder(): string;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.getResolvedProfileFolderAsync}
|
||||
*/
|
||||
getResolvedProfileFolderAsync(): Promise<string>;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.tryResolveConfigFilePath}
|
||||
*/
|
||||
tryResolveConfigFilePath(configFileRelativePath: string): string | undefined;
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.tryResolveConfigFilePathAsync}
|
||||
*/
|
||||
tryResolveConfigFilePathAsync(configFileRelativePath: string): Promise<string | undefined>;
|
||||
private static _validateSchema;
|
||||
}
|
||||
//# sourceMappingURL=RigConfig.d.ts.map
|
1
node_modules/@rushstack/rig-package/lib/RigConfig.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/rig-package/lib/RigConfig.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"RigConfig.d.ts","sourceRoot":"","sources":["../src/RigConfig.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAWD;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,qBAAqB,CAAC,EAAE,cAAc,CAAC;IAEvC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAE3C;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAE3C;;;;;;;;;OASG;IACH,wBAAwB,IAAI,MAAM,CAAC;IAEnC;;OAEG;IACH,6BAA6B,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,wBAAwB,CAAC,sBAAsB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAE7E;;OAEG;IACH,6BAA6B,CAAC,sBAAsB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5F;AAED;;;;GAIG;AACH,qBAAa,SAAU,YAAW,UAAU;IAE1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAwD;IAIlG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAA2B;IAGjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAA6C;IAEvF;;;;;;;;;OASG;IACH,OAAc,cAAc,EAAE,MAAM,CAAwD;IAC5F,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAiC;IAEjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAqC;IAEzE;;OAEG;IACH,SAAgB,yBAAyB,EAAE,MAAM,CAAC;IAElD;;OAEG;IACH,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAE1C;;OAEG;IACH,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAElC;;OAEG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,SAAgB,cAAc,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,SAAgB,yBAAyB,EAAE,MAAM,CAAC;IAIlD,OAAO,CAAC,yBAAyB,CAAqB;IAItD,OAAO,CAAC,sBAAsB,CAAqB;IAEnD,OAAO;IAkBP;;;;;;;OAOG;IACH,WAAkB,gBAAgB,IAAI,MAAM,CAM3C;IAED;;;;;;OAMG;WACW,oBAAoB,CAAC,OAAO,EAAE,4BAA4B,GAAG,SAAS;IA2CpF;;OAEG;WACiB,yBAAyB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,SAAS,CAAC;IA0CxG,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAoBjC;;OAEG;IACI,wBAAwB,IAAI,MAAM;IA8BzC;;OAEG;IACU,6BAA6B,IAAI,OAAO,CAAC,MAAM,CAAC;IA8B7D;;OAEG;IACI,wBAAwB,CAAC,sBAAsB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAkBnF;;OAEG;IACU,6BAA6B,CAAC,sBAAsB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAqBvG,OAAO,CAAC,MAAM,CAAC,eAAe;CAoC/B"}
|
295
node_modules/@rushstack/rig-package/lib/RigConfig.js
generated
vendored
Normal file
295
node_modules/@rushstack/rig-package/lib/RigConfig.js
generated
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RigConfig = void 0;
|
||||
const path = __importStar(require("path"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const nodeResolve = __importStar(require("resolve"));
|
||||
const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
|
||||
const Helpers_1 = require("./Helpers");
|
||||
/**
|
||||
* {@inheritdoc IRigConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
class RigConfig {
|
||||
constructor(options) {
|
||||
const { projectFolderPath, rigFound, filePath, rigPackageName, rigProfile = 'default' } = options;
|
||||
this.projectFolderOriginalPath = projectFolderPath;
|
||||
this.projectFolderPath = path.resolve(projectFolderPath);
|
||||
this.rigFound = rigFound;
|
||||
this.filePath = filePath;
|
||||
this.rigPackageName = rigPackageName;
|
||||
this.rigProfile = rigProfile;
|
||||
if (this.rigFound) {
|
||||
this.relativeProfileFolderPath = 'profiles/' + this.rigProfile;
|
||||
}
|
||||
else {
|
||||
this.relativeProfileFolderPath = '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The JSON contents of the {@link RigConfig.jsonSchemaPath} file.
|
||||
*
|
||||
* @remarks
|
||||
* The JSON object will be lazily loaded when this property getter is accessed, and the result
|
||||
* will be cached.
|
||||
* Accessing this property may make a synchronous filesystem call.
|
||||
*/
|
||||
static get jsonSchemaObject() {
|
||||
if (RigConfig._jsonSchemaObject === undefined) {
|
||||
const jsonSchemaContent = fs.readFileSync(RigConfig.jsonSchemaPath).toString();
|
||||
RigConfig._jsonSchemaObject = JSON.parse(jsonSchemaContent);
|
||||
}
|
||||
return RigConfig._jsonSchemaObject;
|
||||
}
|
||||
/**
|
||||
* Use this method to load the `config/rig.json` file for a given project.
|
||||
*
|
||||
* @remarks
|
||||
* If the file cannot be found, an empty `RigConfig` object will be returned with {@link RigConfig.rigFound}
|
||||
* equal to `false`.
|
||||
*/
|
||||
static loadForProjectFolder(options) {
|
||||
const { overrideRigJsonObject, projectFolderPath } = options;
|
||||
const fromCache = !options.bypassCache && !overrideRigJsonObject
|
||||
? RigConfig._configCache.get(projectFolderPath)
|
||||
: undefined;
|
||||
if (fromCache) {
|
||||
return fromCache;
|
||||
}
|
||||
const rigConfigFilePath = path.join(projectFolderPath, 'config/rig.json');
|
||||
let config;
|
||||
let json = overrideRigJsonObject;
|
||||
try {
|
||||
if (!json) {
|
||||
const rigConfigFileContent = fs.readFileSync(rigConfigFilePath).toString();
|
||||
json = JSON.parse((0, strip_json_comments_1.default)(rigConfigFileContent));
|
||||
}
|
||||
RigConfig._validateSchema(json);
|
||||
}
|
||||
catch (error) {
|
||||
config = RigConfig._handleConfigError(error, projectFolderPath, rigConfigFilePath);
|
||||
}
|
||||
if (!config) {
|
||||
config = new RigConfig({
|
||||
projectFolderPath: projectFolderPath,
|
||||
rigFound: true,
|
||||
filePath: rigConfigFilePath,
|
||||
rigPackageName: json.rigPackageName,
|
||||
rigProfile: json.rigProfile
|
||||
});
|
||||
}
|
||||
if (!overrideRigJsonObject) {
|
||||
RigConfig._configCache.set(projectFolderPath, config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
/**
|
||||
* An async variant of {@link RigConfig.loadForProjectFolder}
|
||||
*/
|
||||
static async loadForProjectFolderAsync(options) {
|
||||
const { overrideRigJsonObject, projectFolderPath } = options;
|
||||
const fromCache = !options.bypassCache && !overrideRigJsonObject && RigConfig._configCache.get(projectFolderPath);
|
||||
if (fromCache) {
|
||||
return fromCache;
|
||||
}
|
||||
const rigConfigFilePath = path.join(projectFolderPath, 'config/rig.json');
|
||||
let config;
|
||||
let json = overrideRigJsonObject;
|
||||
try {
|
||||
if (!json) {
|
||||
const rigConfigFileContent = (await fs.promises.readFile(rigConfigFilePath)).toString();
|
||||
json = JSON.parse((0, strip_json_comments_1.default)(rigConfigFileContent));
|
||||
}
|
||||
RigConfig._validateSchema(json);
|
||||
}
|
||||
catch (error) {
|
||||
config = RigConfig._handleConfigError(error, projectFolderPath, rigConfigFilePath);
|
||||
}
|
||||
if (!config) {
|
||||
config = new RigConfig({
|
||||
projectFolderPath: projectFolderPath,
|
||||
rigFound: true,
|
||||
filePath: rigConfigFilePath,
|
||||
rigPackageName: json.rigPackageName,
|
||||
rigProfile: json.rigProfile
|
||||
});
|
||||
}
|
||||
if (!overrideRigJsonObject) {
|
||||
RigConfig._configCache.set(projectFolderPath, config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
static _handleConfigError(error, projectFolderPath, rigConfigFilePath) {
|
||||
if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') {
|
||||
throw new Error(error.message + '\nError loading config file: ' + rigConfigFilePath);
|
||||
}
|
||||
// File not found, i.e. no rig config
|
||||
return new RigConfig({
|
||||
projectFolderPath,
|
||||
rigFound: false,
|
||||
filePath: '',
|
||||
rigPackageName: '',
|
||||
rigProfile: ''
|
||||
});
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.getResolvedProfileFolder}
|
||||
*/
|
||||
getResolvedProfileFolder() {
|
||||
if (this._resolvedRigPackageFolder === undefined) {
|
||||
if (!this.rigFound) {
|
||||
throw new Error('Cannot resolve the rig package because no rig was specified for this project');
|
||||
}
|
||||
const rigPackageJsonModuleSpecifier = `${this.rigPackageName}/package.json`;
|
||||
const resolveOptions = { basedir: this.projectFolderPath };
|
||||
const resolvedRigPackageJsonPath = nodeResolve.sync(rigPackageJsonModuleSpecifier, resolveOptions);
|
||||
this._resolvedRigPackageFolder = path.dirname(resolvedRigPackageJsonPath);
|
||||
}
|
||||
if (this._resolvedProfileFolder === undefined) {
|
||||
this._resolvedProfileFolder = path.join(this._resolvedRigPackageFolder, this.relativeProfileFolderPath);
|
||||
if (!fs.existsSync(this._resolvedProfileFolder)) {
|
||||
throw new Error(`The rig profile "${this.rigProfile}" is not defined` +
|
||||
` by the rig package "${this.rigPackageName}"`);
|
||||
}
|
||||
}
|
||||
return this._resolvedProfileFolder;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.getResolvedProfileFolderAsync}
|
||||
*/
|
||||
async getResolvedProfileFolderAsync() {
|
||||
if (this._resolvedRigPackageFolder === undefined) {
|
||||
if (!this.rigFound) {
|
||||
throw new Error('Cannot resolve the rig package because no rig was specified for this project');
|
||||
}
|
||||
const rigPackageJsonModuleSpecifier = `${this.rigPackageName}/package.json`;
|
||||
const resolveOptions = { basedir: this.projectFolderPath };
|
||||
const resolvedRigPackageJsonPath = await Helpers_1.Helpers.nodeResolveAsync(rigPackageJsonModuleSpecifier, resolveOptions);
|
||||
this._resolvedRigPackageFolder = path.dirname(resolvedRigPackageJsonPath);
|
||||
}
|
||||
if (this._resolvedProfileFolder === undefined) {
|
||||
this._resolvedProfileFolder = path.join(this._resolvedRigPackageFolder, this.relativeProfileFolderPath);
|
||||
if (!(await Helpers_1.Helpers.fsExistsAsync(this._resolvedProfileFolder))) {
|
||||
throw new Error(`The rig profile "${this.rigProfile}" is not defined` +
|
||||
` by the rig package "${this.rigPackageName}"`);
|
||||
}
|
||||
}
|
||||
return this._resolvedProfileFolder;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.tryResolveConfigFilePath}
|
||||
*/
|
||||
tryResolveConfigFilePath(configFileRelativePath) {
|
||||
if (!Helpers_1.Helpers.isDownwardRelative(configFileRelativePath)) {
|
||||
throw new Error('The configFileRelativePath is not a relative path: ' + configFileRelativePath);
|
||||
}
|
||||
const localPath = path.join(this.projectFolderPath, configFileRelativePath);
|
||||
if (fs.existsSync(localPath)) {
|
||||
return localPath;
|
||||
}
|
||||
if (this.rigFound) {
|
||||
const riggedPath = path.join(this.getResolvedProfileFolder(), configFileRelativePath);
|
||||
if (fs.existsSync(riggedPath)) {
|
||||
return riggedPath;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc IRigConfig.tryResolveConfigFilePathAsync}
|
||||
*/
|
||||
async tryResolveConfigFilePathAsync(configFileRelativePath) {
|
||||
if (!Helpers_1.Helpers.isDownwardRelative(configFileRelativePath)) {
|
||||
throw new Error('The configFileRelativePath is not a relative path: ' + configFileRelativePath);
|
||||
}
|
||||
const localPath = path.join(this.projectFolderPath, configFileRelativePath);
|
||||
if (await Helpers_1.Helpers.fsExistsAsync(localPath)) {
|
||||
return localPath;
|
||||
}
|
||||
if (this.rigFound) {
|
||||
const riggedPath = path.join(await this.getResolvedProfileFolderAsync(), configFileRelativePath);
|
||||
if (await Helpers_1.Helpers.fsExistsAsync(riggedPath)) {
|
||||
return riggedPath;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
static _validateSchema(json) {
|
||||
for (const key of Object.getOwnPropertyNames(json)) {
|
||||
switch (key) {
|
||||
case '$schema':
|
||||
case 'rigPackageName':
|
||||
case 'rigProfile':
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported field ${JSON.stringify(key)}`);
|
||||
}
|
||||
}
|
||||
if (!json.rigPackageName) {
|
||||
throw new Error('Missing required field "rigPackageName"');
|
||||
}
|
||||
if (!RigConfig._packageNameRegExp.test(json.rigPackageName)) {
|
||||
throw new Error(`The "rigPackageName" value is not a valid NPM package name: ${JSON.stringify(json.rigPackageName)}`);
|
||||
}
|
||||
if (!RigConfig._rigNameRegExp.test(json.rigPackageName)) {
|
||||
throw new Error(`The "rigPackageName" value is missing the "-rig" suffix: ` + JSON.stringify(json.rigProfile));
|
||||
}
|
||||
if (json.rigProfile !== undefined) {
|
||||
if (!RigConfig._profileNameRegExp.test(json.rigProfile)) {
|
||||
throw new Error(`The profile name must consist of lowercase alphanumeric words separated by hyphens: ` +
|
||||
JSON.stringify(json.rigProfile));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// For syntax details, see PackageNameParser from @rushstack/node-core-library
|
||||
RigConfig._packageNameRegExp = /^(@[A-Za-z0-9\-_\.]+\/)?[A-Za-z0-9\-_\.]+$/;
|
||||
// Rig package names must have the "-rig" suffix.
|
||||
// Also silently accept "-rig-test" for our build test projects.
|
||||
RigConfig._rigNameRegExp = /-rig(-test)?$/;
|
||||
// Profiles must be lowercase alphanumeric words separated by hyphens
|
||||
RigConfig._profileNameRegExp = /^[a-z0-9_\.]+(\-[a-z0-9_\.]+)*$/;
|
||||
/**
|
||||
* Returns the absolute path of the `rig.schema.json` JSON schema file for `config/rig.json`,
|
||||
* which is bundled with this NPM package.
|
||||
*
|
||||
* @remarks
|
||||
* The `RigConfig` class already performs schema validation when loading `rig.json`; however
|
||||
* this schema file may be useful for integration with other validation tools.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
RigConfig.jsonSchemaPath = path.resolve(__dirname, './schemas/rig.schema.json');
|
||||
RigConfig._jsonSchemaObject = undefined;
|
||||
RigConfig._configCache = new Map();
|
||||
exports.RigConfig = RigConfig;
|
||||
//# sourceMappingURL=RigConfig.js.map
|
1
node_modules/@rushstack/rig-package/lib/RigConfig.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/rig-package/lib/RigConfig.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/@rushstack/rig-package/lib/index.d.ts
generated
vendored
Normal file
12
node_modules/@rushstack/rig-package/lib/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* A system for sharing tool configurations between projects without duplicating config files.
|
||||
*
|
||||
* @remarks
|
||||
* The `config/rig.json` file is a system that Node.js build tools can support, in order to eliminate
|
||||
* duplication of config files when many projects share a common configuration. This is particularly valuable
|
||||
* in a setup where hundreds of projects may be built using a small set of reusable recipes.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
export { type IRigConfigJson, type IRigConfig, RigConfig, type ILoadForProjectFolderOptions } from './RigConfig';
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/@rushstack/rig-package/lib/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@rushstack/rig-package/lib/index.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,SAAS,EACT,KAAK,4BAA4B,EAClC,MAAM,aAAa,CAAC"}
|
18
node_modules/@rushstack/rig-package/lib/index.js
generated
vendored
Normal file
18
node_modules/@rushstack/rig-package/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||
// See LICENSE in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RigConfig = void 0;
|
||||
/**
|
||||
* A system for sharing tool configurations between projects without duplicating config files.
|
||||
*
|
||||
* @remarks
|
||||
* The `config/rig.json` file is a system that Node.js build tools can support, in order to eliminate
|
||||
* duplication of config files when many projects share a common configuration. This is particularly valuable
|
||||
* in a setup where hundreds of projects may be built using a small set of reusable recipes.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
var RigConfig_1 = require("./RigConfig");
|
||||
Object.defineProperty(exports, "RigConfig", { enumerable: true, get: function () { return RigConfig_1.RigConfig; } });
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@rushstack/rig-package/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@rushstack/rig-package/lib/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;;;;GASG;AAEH,yCAKqB;AAFnB,sGAAA,SAAS,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * A system for sharing tool configurations between projects without duplicating config files.\n *\n * @remarks\n * The `config/rig.json` file is a system that Node.js build tools can support, in order to eliminate\n * duplication of config files when many projects share a common configuration. This is particularly valuable\n * in a setup where hundreds of projects may be built using a small set of reusable recipes.\n *\n * @packageDocumentation\n */\n\nexport {\n type IRigConfigJson,\n type IRigConfig,\n RigConfig,\n type ILoadForProjectFolderOptions\n} from './RigConfig';\n"]}
|
27
node_modules/@rushstack/rig-package/lib/schemas/rig.schema.json
generated
vendored
Normal file
27
node_modules/@rushstack/rig-package/lib/schemas/rig.schema.json
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "Describes the config/rig.json file",
|
||||
"description": "The rig.json file is a standard for sharing project configuration in a monorepo without duplicating files",
|
||||
"type": "object",
|
||||
|
||||
"additionalProperties": false,
|
||||
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
"rigPackageName": {
|
||||
"type": "string",
|
||||
"description": "(Required) The name of the rig package to inherit from. It should be an NPM package name with the \"-rig\" suffix."
|
||||
},
|
||||
|
||||
"rigProfile": {
|
||||
"type": "string",
|
||||
"description": "Selects a config profile from the rig package. The name must consist of lowercase alphanumeric words separated by hyphens, for example \"sample-profile\". If omitted, then the \"default\" profile will be used."
|
||||
}
|
||||
},
|
||||
|
||||
"required": ["rigPackageName"]
|
||||
}
|
32
node_modules/@rushstack/rig-package/package.json
generated
vendored
Normal file
32
node_modules/@rushstack/rig-package/package.json
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@rushstack/rig-package",
|
||||
"version": "0.5.1",
|
||||
"description": "A system for sharing tool configurations between projects without duplicating config files.",
|
||||
"main": "lib/index.js",
|
||||
"typings": "dist/rig-package.d.ts",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "https://github.com/microsoft/rushstack.git",
|
||||
"type": "git",
|
||||
"directory": "libraries/rig-package"
|
||||
},
|
||||
"dependencies": {
|
||||
"resolve": "~1.22.1",
|
||||
"strip-json-comments": "~3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rushstack/heft-node-rig": "2.2.23",
|
||||
"@rushstack/heft": "0.59.0",
|
||||
"@types/heft-jest": "1.0.1",
|
||||
"@types/node": "18.17.15",
|
||||
"@types/resolve": "1.20.2",
|
||||
"ajv": "~6.12.5",
|
||||
"resolve": "~1.22.1",
|
||||
"local-eslint-config": "1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "heft build --clean",
|
||||
"_phase:build": "heft run --only build -- --clean",
|
||||
"_phase:test": "heft run --only test -- --clean"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user