Updated the files.

This commit is contained in:
Batuhan Berk Başoğlu 2024-02-08 19:38:41 -05:00
parent 1553e6b971
commit 753967d4f5
23418 changed files with 3784666 additions and 0 deletions

View file

@ -0,0 +1,14 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { BaseException } from '@angular-devkit/core';
import { TaskExecutor } from '../../src';
import { NodePackageTaskFactoryOptions, NodePackageTaskOptions } from './options';
export declare class UnknownPackageManagerException extends BaseException {
constructor(name: string);
}
export default function (factoryOptions?: NodePackageTaskFactoryOptions): TaskExecutor<NodePackageTaskOptions>;

View file

@ -0,0 +1,161 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
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.UnknownPackageManagerException = void 0;
const core_1 = require("@angular-devkit/core");
const child_process_1 = require("child_process");
const ora_1 = __importDefault(require("ora"));
const path = __importStar(require("path"));
const rxjs_1 = require("rxjs");
const src_1 = require("../../src");
const packageManagers = {
'npm': {
commands: {
installAll: 'install',
installPackage: 'install',
},
},
'cnpm': {
commands: {
installAll: 'install',
installPackage: 'install',
},
},
'yarn': {
commands: {
installPackage: 'add',
},
},
'pnpm': {
commands: {
installAll: 'install',
installPackage: 'install',
},
},
};
class UnknownPackageManagerException extends core_1.BaseException {
constructor(name) {
super(`Unknown package manager "${name}".`);
}
}
exports.UnknownPackageManagerException = UnknownPackageManagerException;
function default_1(factoryOptions = {}) {
const packageManagerName = factoryOptions.packageManager || 'npm';
const packageManagerProfile = packageManagers[packageManagerName];
if (!packageManagerProfile) {
throw new UnknownPackageManagerException(packageManagerName);
}
const rootDirectory = factoryOptions.rootDirectory || process.cwd();
return (options = { command: 'install' }) => {
let taskPackageManagerProfile = packageManagerProfile;
let taskPackageManagerName = packageManagerName;
if (factoryOptions.allowPackageManagerOverride && options.packageManager) {
taskPackageManagerProfile = packageManagers[options.packageManager];
if (!taskPackageManagerProfile) {
throw new UnknownPackageManagerException(options.packageManager);
}
taskPackageManagerName = options.packageManager;
}
const bufferedOutput = [];
const spawnOptions = {
shell: true,
cwd: path.join(rootDirectory, options.workingDirectory || ''),
};
if (options.hideOutput) {
spawnOptions.stdio = options.quiet ? ['ignore', 'ignore', 'pipe'] : 'pipe';
}
else {
spawnOptions.stdio = options.quiet ? ['ignore', 'ignore', 'inherit'] : 'inherit';
}
const args = [];
if (options.packageName) {
if (options.command === 'install') {
args.push(taskPackageManagerProfile.commands.installPackage);
}
args.push(options.packageName);
}
else if (options.command === 'install' && taskPackageManagerProfile.commands.installAll) {
args.push(taskPackageManagerProfile.commands.installAll);
}
if (!options.allowScripts) {
// Yarn requires special handling since Yarn 2+ no longer has the `--ignore-scripts` flag
if (taskPackageManagerName === 'yarn') {
spawnOptions.env = {
...process.env,
// Supported with yarn 1
'npm_config_ignore_scripts': 'true',
// Supported with yarn 2+
'YARN_ENABLE_SCRIPTS': 'false',
};
}
else {
args.push('--ignore-scripts');
}
}
if (factoryOptions.registry) {
args.push(`--registry="${factoryOptions.registry}"`);
}
if (factoryOptions.force) {
args.push('--force');
}
return new rxjs_1.Observable((obs) => {
const spinner = (0, ora_1.default)({
text: `Installing packages (${taskPackageManagerName})...`,
// Workaround for https://github.com/sindresorhus/ora/issues/136.
discardStdin: process.platform != 'win32',
}).start();
const childProcess = (0, child_process_1.spawn)(taskPackageManagerName, args, spawnOptions).on('close', (code) => {
if (code === 0) {
spinner.succeed('Packages installed successfully.');
spinner.stop();
obs.next();
obs.complete();
}
else {
if (options.hideOutput) {
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
}
spinner.fail('Package install failed, see above.');
obs.error(new src_1.UnsuccessfulWorkflowExecution());
}
});
if (options.hideOutput) {
childProcess.stdout?.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
childProcess.stderr?.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
}
});
};
}
exports.default = default_1;

View file

@ -0,0 +1,29 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { TaskConfiguration, TaskConfigurationGenerator } from '../../src';
import { NodePackageTaskOptions } from './options';
interface NodePackageInstallTaskOptions {
packageManager?: string;
packageName?: string;
workingDirectory?: string;
quiet?: boolean;
hideOutput?: boolean;
allowScripts?: boolean;
}
export declare class NodePackageInstallTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
quiet: boolean;
hideOutput: boolean;
allowScripts: boolean;
workingDirectory?: string;
packageManager?: string;
packageName?: string;
constructor(workingDirectory?: string);
constructor(options: NodePackageInstallTaskOptions);
toConfiguration(): TaskConfiguration<NodePackageTaskOptions>;
}
export {};

View file

@ -0,0 +1,59 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodePackageInstallTask = void 0;
const options_1 = require("./options");
class NodePackageInstallTask {
quiet = true;
hideOutput = true;
allowScripts = false;
workingDirectory;
packageManager;
packageName;
constructor(options) {
if (typeof options === 'string') {
this.workingDirectory = options;
}
else if (typeof options === 'object') {
if (options.quiet != undefined) {
this.quiet = options.quiet;
}
if (options.hideOutput != undefined) {
this.hideOutput = options.hideOutput;
}
if (options.workingDirectory != undefined) {
this.workingDirectory = options.workingDirectory;
}
if (options.packageManager != undefined) {
this.packageManager = options.packageManager;
}
if (options.packageName != undefined) {
this.packageName = options.packageName;
}
if (options.allowScripts !== undefined) {
this.allowScripts = options.allowScripts;
}
}
}
toConfiguration() {
return {
name: options_1.NodePackageName,
options: {
command: 'install',
quiet: this.quiet,
hideOutput: this.hideOutput,
workingDirectory: this.workingDirectory,
packageManager: this.packageManager,
packageName: this.packageName,
allowScripts: this.allowScripts,
},
};
}
}
exports.NodePackageInstallTask = NodePackageInstallTask;

View file

@ -0,0 +1,16 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { TaskConfiguration, TaskConfigurationGenerator } from '../../src';
import { NodePackageTaskOptions } from './options';
export declare class NodePackageLinkTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
packageName?: string | undefined;
workingDirectory?: string | undefined;
quiet: boolean;
constructor(packageName?: string | undefined, workingDirectory?: string | undefined);
toConfiguration(): TaskConfiguration<NodePackageTaskOptions>;
}

View file

@ -0,0 +1,32 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodePackageLinkTask = void 0;
const options_1 = require("./options");
class NodePackageLinkTask {
packageName;
workingDirectory;
quiet = true;
constructor(packageName, workingDirectory) {
this.packageName = packageName;
this.workingDirectory = workingDirectory;
}
toConfiguration() {
return {
name: options_1.NodePackageName,
options: {
command: 'link',
quiet: this.quiet,
workingDirectory: this.workingDirectory,
packageName: this.packageName,
},
};
}
}
exports.NodePackageLinkTask = NodePackageLinkTask;

View file

@ -0,0 +1,24 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
export declare const NodePackageName = "node-package";
export interface NodePackageTaskFactoryOptions {
rootDirectory?: string;
packageManager?: string;
allowPackageManagerOverride?: boolean;
registry?: string;
force?: boolean;
}
export interface NodePackageTaskOptions {
command: string;
quiet?: boolean;
hideOutput?: boolean;
workingDirectory?: string;
packageName?: string;
packageManager?: string;
allowScripts?: boolean;
}

View file

@ -0,0 +1,11 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodePackageName = void 0;
exports.NodePackageName = 'node-package';