liferay-npm-bundler-preset-reactjs
Version:
liferay npm bundler preset react
162 lines (161 loc) • 5.01 kB
TypeScript
/**
* SPDX-FileCopyrightText: © 2020 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
import FilePath from '../file-path';
import Copy from './copy';
import Jar from './jar';
import Localization from './localization';
import Misc from './misc';
import Probe from './probe';
import Rules from './rules';
import Transform from './transform';
import { VersionInfo } from './types';
export { ProjectType } from './probe';
/** A package manager */
export declare type PkgManager = 'npm' | 'yarn' | null;
/** Information on the preset being used */
export interface PresetInfo {
isAutopreset: boolean;
name: string;
}
declare type AnyObject = {
[key: string]: any;
};
/**
* Describes a standard JS Toolkit project.
*/
export declare class Project {
copy: Copy;
jar: Jar;
l10n: Localization;
misc: Misc;
probe: Probe;
rules: Rules;
transform: Transform;
/**
* @param projectDirPath project's path in native format
*/
constructor(projectDirPath: string);
/**
* Get directories inside the project containing source files starting with
* `./` (so that they can be safely path.joined)
*/
get sources(): FilePath[];
/**
* Get directory where files to be transformed live relative to
* `this.dir` and starting with `./` (so that it can be safely path.joined)
*/
get buildDir(): FilePath;
/**
* Get absolute path to project's directory.
*/
get dir(): FilePath;
/**
* Get global plugins configuration.
*/
get globalConfig(): AnyObject;
/**
* Get project's parsed .npmbundlerrc file
*/
get npmbundlerrc(): object;
/**
* Get project's parsed package.json file
*/
get pkgJson(): AnyObject;
/**
* Return the package manager that the project is using or null if it cannot
* be inferred.
*/
get pkgManager(): PkgManager;
/**
* Get information about the preset in use
*/
get presetInfo(): PresetInfo | undefined;
/**
* Get all available information about versions of plugins and presets used
* for the build.
* @return a Map where keys are package names
*/
get versionsInfo(): Map<string, VersionInfo>;
/**
* Reload the whole project from given directory. Especially useful for
* tests.
* @param projectPath
* project's path in native format (whether absolute or relative to cwd)
* @param configFilePath
* optional path to configuration file (relative to `projectPath` if not
* given as an absolute path)
*/
loadFrom(projectPath: string, configFilePath?: string): void;
/**
* Requires a module in the context of the project (as opposed to the
* context of the calling package which would just use a normal `require()`
* call).
* @param moduleName
*/
require(moduleName: string): any;
/**
* Resolves a module in the context of the project (as opposed to the
* context of the calling package which would just use a normal
* `require.resolve()` call).
* @param moduleName
*/
resolve(moduleName: string): string;
/**
* Set program arguments so that some of them can be parsed as if they were
* `.npmbundlerrc` options.
*/
set argv(argv: {
'config': string;
'create-jar': boolean;
'dump-report': boolean;
});
/**
* Requires a tool module in the context of the project (as opposed to the
* context of the calling package which would just use a normal `require()`
* call).
*
* @remarks
* This looks in the `.npmbundlerrc` preset before calling the standard
* {@link require} method.
*
* @param moduleName
* @throws if module is not found
*/
toolRequire(moduleName: string): any;
/**
* Resolves a tool module in the context of the project (as opposed to the
* context of the calling package which would just use a normal
* `require.resolve()` call).
*
* @remarks
* This looks in the `.npmbundlerrc` preset before calling the standard
* {@link require} method.x
*
* @param moduleName
* @throws if module is not found
*/
toolResolve(moduleName: string): string;
_getAutopreset(): string | null;
_loadNpmbundlerrc(): void;
_loadPkgJson(): void;
/** Project relative path to build directory */
private _buildDir;
/** Absolute path to config file */
private _configFile;
private _npmbundlerrc;
private _pkgJson;
private _pkgManager;
/** Info about preset in use */
private _presetInfo;
/** Absolute path to project directory */
private _projectDir;
/** Project relative paths to source directories */
private _sources;
/** Absolute path to tools directory (usually project or preset dir) */
private _toolsDir;
private _versionsInfo;
}
declare const _default: Project;
export default _default;