Socket
Socket
Sign inDemoInstall

@rushstack/rig-package

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rushstack/rig-package - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

lib/Helpers.d.ts

34

CHANGELOG.json

@@ -5,2 +5,36 @@ {

{
"version": "0.2.0",
"tag": "@rushstack/rig-package_v0.2.0",
"date": "Wed, 30 Sep 2020 06:53:53 GMT",
"comments": {
"minor": [
{
"comment": "Update the rig package guidance to place tool configuration files that would normally be in a \"config\" folder in a \"config\" folder inside the rig package as well."
},
{
"comment": "Add ILoadForProjectFolderOptions.overrideRigJsonObject"
},
{
"comment": "Add RigConfig.tryResolveConfigFilePath()"
},
{
"comment": "Upgrade compiler; the API now requires TypeScript 3.9 or newer"
}
],
"patch": [
{
"comment": "Report an error if the specified \"rigProfile\" is not defined by the rig package"
},
{
"comment": "Update README.md"
}
],
"dependency": [
{
"comment": "Updating dependency \"@rushstack/eslint-config\" to `2.1.2`"
}
]
}
},
{
"version": "0.1.0",

@@ -7,0 +41,0 @@ "tag": "@rushstack/rig-package_v0.1.0",

17

CHANGELOG.md
# Change Log - @rushstack/rig-package
This log was last generated on Fri, 25 Sep 2020 08:13:01 GMT and should not be manually modified.
This log was last generated on Wed, 30 Sep 2020 06:53:53 GMT and should not be manually modified.
## 0.2.0
Wed, 30 Sep 2020 06:53:53 GMT
### Minor changes
- Update the rig package guidance to place tool configuration files that would normally be in a "config" folder in a "config" folder inside the rig package as well.
- Add ILoadForProjectFolderOptions.overrideRigJsonObject
- Add RigConfig.tryResolveConfigFilePath()
- Upgrade compiler; the API now requires TypeScript 3.9 or newer
### Patches
- Report an error if the specified "rigProfile" is not defined by the rig package
- Update README.md
## 0.1.0

@@ -6,0 +21,0 @@ Fri, 25 Sep 2020 08:13:01 GMT

@@ -23,5 +23,36 @@ /**

projectFolderPath: string;
/**
* If specified, instead of loading the `config/rig.json` from disk, this object will be substituted instead.
*/
overrideRigJsonObject?: IRigConfigJson;
}
/**
* 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;
}
/**
* This is the main API for loading the `config/rig.json` file format.

@@ -48,5 +79,13 @@ *

/**
* The project folder path that was passed to {@link RigConfig.loadForProjectFolder}.
* 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`

@@ -94,2 +133,3 @@ */

private _resolvedRigPackageFolder;
private _resolvedProfileFolder;
private constructor();

@@ -104,3 +144,3 @@ /**

*/
static readonly jsonSchemaObject: object;
static get jsonSchemaObject(): object;
/**

@@ -123,3 +163,4 @@ * Use this method to load the `config/rig.json` file for a given project.

* @remarks
* If no `rig.json` file was found, then this method throws an error.
* 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.
*

@@ -133,3 +174,23 @@ * Example: `/path/to/your-project/node_modules/example-rig/profiles/example-profile`

getResolvedProfileFolderAsync(): Promise<string>;
private _getResolvedRigPackageFolder;
/**
* 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 RigConfig.tryResolveConfigFilePath}
*/
tryResolveConfigFilePathAsync(configFileRelativePath: string): Promise<string | undefined>;
private static _validateSchema;

@@ -136,0 +197,0 @@ }

2

lib/index.d.ts

@@ -11,3 +11,3 @@ /**

*/
export { RigConfig, ILoadForProjectFolderOptions } from './RigConfig';
export { IRigConfigJson, RigConfig, ILoadForProjectFolderOptions } from './RigConfig';
//# sourceMappingURL=index.d.ts.map

@@ -16,3 +16,3 @@ "use strict";

var RigConfig_1 = require("./RigConfig");
exports.RigConfig = RigConfig_1.RigConfig;
Object.defineProperty(exports, "RigConfig", { enumerable: true, get: function () { return RigConfig_1.RigConfig; } });
//# sourceMappingURL=index.js.map
/**
* 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}.

@@ -11,2 +37,6 @@ *

projectFolderPath: string;
/**
* If specified, instead of loading the `config/rig.json` from disk, this object will be substituted instead.
*/
overrideRigJsonObject?: IRigConfigJson;
}

@@ -35,5 +65,13 @@ /**

/**
* The project folder path that was passed to {@link RigConfig.loadForProjectFolder}.
* 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`

@@ -81,2 +119,3 @@ */

private _resolvedRigPackageFolder;
private _resolvedProfileFolder;
private constructor();

@@ -91,3 +130,3 @@ /**

*/
static readonly jsonSchemaObject: object;
static get jsonSchemaObject(): object;
/**

@@ -110,3 +149,4 @@ * Use this method to load the `config/rig.json` file for a given project.

* @remarks
* If no `rig.json` file was found, then this method throws an error.
* 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.
*

@@ -120,5 +160,25 @@ * Example: `/path/to/your-project/node_modules/example-rig/profiles/example-profile`

getResolvedProfileFolderAsync(): Promise<string>;
private _getResolvedRigPackageFolder;
/**
* 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 RigConfig.tryResolveConfigFilePath}
*/
tryResolveConfigFilePathAsync(configFileRelativePath: string): Promise<string | undefined>;
private static _validateSchema;
}
//# sourceMappingURL=RigConfig.d.ts.map

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RigConfig = void 0;
const path = require("path");

@@ -10,2 +11,3 @@ const fs = require("fs");

const stripJsonComments = require("strip-json-comments");
const Helpers_1 = require("./Helpers");
/**

@@ -18,3 +20,4 @@ * This is the main API for loading the `config/rig.json` file format.

constructor(options) {
this.projectFolderPath = options.projectFolderPath;
this.projectFolderOriginalPath = options.projectFolderPath;
this.projectFolderPath = path.resolve(options.projectFolderPath);
this.rigFound = options.rigFound;

@@ -55,15 +58,20 @@ this.filePath = options.filePath;

const rigConfigFilePath = path.join(options.projectFolderPath, 'config/rig.json');
if (!fs.existsSync(rigConfigFilePath)) {
return new RigConfig({
projectFolderPath: options.projectFolderPath,
rigFound: false,
filePath: '',
rigPackageName: '',
rigProfile: ''
});
}
let json;
try {
const rigConfigFileContent = fs.readFileSync(rigConfigFilePath).toString();
json = JSON.parse(stripJsonComments(rigConfigFileContent));
if (options.overrideRigJsonObject) {
json = options.overrideRigJsonObject;
}
else {
if (!fs.existsSync(rigConfigFilePath)) {
return new RigConfig({
projectFolderPath: options.projectFolderPath,
rigFound: false,
filePath: '',
rigPackageName: '',
rigProfile: ''
});
}
const rigConfigFileContent = fs.readFileSync(rigConfigFilePath).toString();
json = JSON.parse(stripJsonComments(rigConfigFileContent));
}
RigConfig._validateSchema(json);

@@ -87,16 +95,20 @@ }

const rigConfigFilePath = path.join(options.projectFolderPath, 'config/rig.json');
const rigConfigFilePathExists = await new Promise((resolve) => fs.exists(rigConfigFilePath, resolve));
if (!rigConfigFilePathExists) {
return new RigConfig({
projectFolderPath: options.projectFolderPath,
rigFound: false,
filePath: '',
rigPackageName: '',
rigProfile: ''
});
}
let json;
try {
const rigConfigFileContent = (await fs.promises.readFile(rigConfigFilePath)).toString();
json = JSON.parse(stripJsonComments(rigConfigFileContent));
if (options.overrideRigJsonObject) {
json = options.overrideRigJsonObject;
}
else {
if (!(await Helpers_1.Helpers.fsExistsAsync(rigConfigFilePath))) {
return new RigConfig({
projectFolderPath: options.projectFolderPath,
rigFound: false,
filePath: '',
rigPackageName: '',
rigProfile: ''
});
}
const rigConfigFileContent = (await fs.promises.readFile(rigConfigFilePath)).toString();
json = JSON.parse(stripJsonComments(rigConfigFileContent));
}
RigConfig._validateSchema(json);

@@ -120,3 +132,4 @@ }

* @remarks
* If no `rig.json` file was found, then this method throws an error.
* 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.
*

@@ -126,4 +139,19 @@ * Example: `/path/to/your-project/node_modules/example-rig/profiles/example-profile`

getResolvedProfileFolder() {
const resolvedRigPackageFolder = this._getResolvedRigPackageFolder(false);
return path.join(resolvedRigPackageFolder, this.relativeProfileFolderPath);
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;
}

@@ -134,15 +162,3 @@ /**

async getResolvedProfileFolderAsync() {
const resolvedRigPackageFolder = await this._getResolvedRigPackageFolder(true);
return path.join(resolvedRigPackageFolder, this.relativeProfileFolderPath);
}
_getResolvedRigPackageFolder(async) {
if (this._resolvedRigPackageFolder !== undefined) {
if (async) {
return Promise.resolve(this._resolvedRigPackageFolder);
}
else {
return this._resolvedRigPackageFolder;
}
}
else {
if (this._resolvedRigPackageFolder === undefined) {
if (!this.rigFound) {

@@ -153,25 +169,65 @@ throw new Error('Cannot resolve the rig package because no rig was specified for this project');

const resolveOptions = { basedir: this.projectFolderPath };
if (async) {
const resolvePromise = new Promise((resolve, reject) => {
nodeResolve(rigPackageJsonModuleSpecifier, resolveOptions, (error, result) => {
if (error) {
reject(error);
}
else {
resolve(result);
}
});
});
return resolvePromise.then((resolvedRigPackageJsonPath) => {
this._resolvedRigPackageFolder = path.dirname(resolvedRigPackageJsonPath);
return this._resolvedRigPackageFolder;
});
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}"`);
}
else {
const resolvedRigPackageJsonPath = nodeResolve.sync(rigPackageJsonModuleSpecifier, resolveOptions);
this._resolvedRigPackageFolder = path.dirname(resolvedRigPackageJsonPath);
return this._resolvedRigPackageFolder;
}
return this._resolvedProfileFolder;
}
/**
* 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) {
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;
}
/**
* An async variant of {@link RigConfig.tryResolveConfigFilePath}
*/
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) {

@@ -205,2 +261,3 @@ for (const key of Object.getOwnPropertyNames(json)) {

}
exports.RigConfig = RigConfig;
// For syntax details, see PackageNameParser from @rushstack/node-core-library

@@ -225,3 +282,2 @@ RigConfig._packageNameRegExp = /^(@[A-Za-z0-9\-_\.]+\/)?[A-Za-z0-9\-_\.]+$/;

RigConfig._jsonSchemaObject = undefined;
exports.RigConfig = RigConfig;
//# sourceMappingURL=RigConfig.js.map
{
"name": "@rushstack/rig-package",
"version": "0.1.0",
"version": "0.2.0",
"description": "A system for sharing tool configurations between projects without duplicating config files.",

@@ -20,8 +20,7 @@ "main": "lib/index.js",

"devDependencies": {
"@microsoft/rush-stack-compiler-3.5": "0.8.21",
"@rushstack/eslint-config": "2.1.1",
"@rushstack/heft": "0.13.9",
"@microsoft/rush-stack-compiler-3.9": "0.4.21",
"@rushstack/eslint-config": "2.1.2",
"@rushstack/heft": "0.8.0",
"@types/heft-jest": "1.0.1",
"@types/resolve": "1.17.1",
"@types/strip-json-comments": "3.0.0",
"ajv": "~6.12.5",

@@ -28,0 +27,0 @@ "resolve": "~1.17.0"

# @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
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.

@@ -10,3 +10,3 @@

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
configuration from **\<projectFolder\>/config/api-extractor.json**. Suppose that we have three separate projects
that all share the exact same configuration:

@@ -17,3 +17,4 @@

project1/config/api-extractor.json
project1/config/other-tool.json
project1/config/other-tool2.json
project1/config/other-tool3.json
project1/src/index.ts

@@ -23,3 +24,4 @@

project2/config/api-extractor.json
project2/config/other-tool.json
project2/config/other-tool2.json
project2/config/other-tool3.json
project2/src/index.ts

@@ -29,11 +31,12 @@

project3/config/api-extractor.json
project3/config/other-tool.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
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,
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**:

@@ -43,8 +46,9 @@

example-rig/package.json
example-rig/profile/node-library/api-extractor.json
example-rig/profile/web-library/api-extractor.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-tool.json
project1/config/other-tool2.json
project1/config/other-tool3.json
project1/src/index.ts

@@ -54,3 +58,4 @@

project2/config/api-extractor.json
project2/config/other-tool.json
project2/config/other-tool2.json
project2/config/other-tool3.json
project2/src/index.ts

@@ -60,3 +65,4 @@

project3/config/api-extractor.json
project3/config/other-tool.json
project3/config/other-tool2.json
project3/config/other-tool3.json
project3/src/index.ts

@@ -71,3 +77,3 @@ ```

> **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`.
> rig profiles are user-defined. If you only need one profile, then call it `default`.

@@ -77,6 +83,7 @@ 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/api-extractor.json"
"extends": "example-rig/profile/node-library/config/api-extractor.json"
}

@@ -88,11 +95,12 @@ ```

**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/api-extractor.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
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.

@@ -102,9 +110,9 @@

## rig.json eliminates files entirely
The idea is to replace `config/api-extractor.json` and `config/other-tool.json` (and any other such files)
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

@@ -128,23 +136,24 @@ {

Using **rig.json** eliminates the `"extends"` stub files entirely. A tool that implements the **rig.json** system
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>`
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...
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 custom setting like this:
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/api-extractor.json",
"extends": "example-rig/profile/node-library/config/api-extractor.json",
// Custom setting:
// Local override:
"mainEntryPointFilePath": "<projectFolder>/lib/custom.d.ts",

@@ -158,8 +167,13 @@ }

example-rig/package.json
example-rig/profile/node-library/api-extractor.json
example-rig/profile/web-library/api-extractor.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/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
project1/package.json
project1/config/rig.json
project1/config/api-extractor.json <-- custom setting shown above
project1/config/api-extractor.json <-- local override shown above
project1/src/index.ts

@@ -176,7 +190,6 @@

## The `@rushstack/rig-package` API
## The `@ruhstack/rig-package` API
The `@ruhstack/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
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**.

@@ -192,9 +205,9 @@

// Specify a project folder (i.e. where its package.json file is located)
packageJsonFolderPath: '/path/to/project3'
projectFolderPath: testProjectFolder
});
if (rigConfig.enabled) {
if (rigConfig.rigFound) {
// We found a config/rig.json file
//
// Prints "/path/to/project3"
// Prints "/path/to/project3/config/rig.json"
console.log('Found rig.json: ' + rigConfig.filePath);

@@ -208,5 +221,11 @@

// Prints "/path/to/project3/node_modules/example-rig/profile/web-library"
console.log('Profile folder' + rigConfig.getResolvedProfileFolder());
console.log('Profile folder: ' + rigConfig.getResolvedProfileFolder());
// (Your tool can check this folder for its config file)
// 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'));
}

@@ -217,3 +236,9 @@ ```

## Links
API documentation for this package: https://rushstack.io/pages/api/rig-package/
- [CHANGELOG.md](
https://github.com/microsoft/rushstack/blob/master/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.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc