source: trip-planner-front/node_modules/@angular/compiler-cli/ngcc/src/writing/package_json_updater.d.ts

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/// <amd-module name="@angular/compiler-cli/ngcc/src/writing/package_json_updater" />
9import { AbsoluteFsPath, FileSystem } from '../../../src/ngtsc/file_system';
10import { JsonObject, JsonValue } from '../packages/entry_point';
11export declare type PackageJsonChange = [string[], JsonValue, PackageJsonPropertyPositioning];
12export declare type PackageJsonPropertyPositioning = 'unimportant' | 'alphabetic' | {
13 before: string;
14};
15export declare type WritePackageJsonChangesFn = (changes: PackageJsonChange[], packageJsonPath: AbsoluteFsPath, parsedJson?: JsonObject) => void;
16/**
17 * A utility object that can be used to safely update values in a `package.json` file.
18 *
19 * Example usage:
20 * ```ts
21 * const updatePackageJson = packageJsonUpdater
22 * .createUpdate()
23 * .addChange(['name'], 'package-foo')
24 * .addChange(['scripts', 'foo'], 'echo FOOOO...', 'unimportant')
25 * .addChange(['dependencies', 'baz'], '1.0.0', 'alphabetic')
26 * .addChange(['dependencies', 'bar'], '2.0.0', {before: 'baz'})
27 * .writeChanges('/foo/package.json');
28 * // or
29 * // .writeChanges('/foo/package.json', inMemoryParsedJson);
30 * ```
31 */
32export interface PackageJsonUpdater {
33 /**
34 * Create a `PackageJsonUpdate` object, which provides a fluent API for batching updates to a
35 * `package.json` file. (Batching the updates is useful, because it avoids unnecessary I/O
36 * operations.)
37 */
38 createUpdate(): PackageJsonUpdate;
39 /**
40 * Write a set of changes to the specified `package.json` file (and optionally a pre-existing,
41 * in-memory representation of it).
42 *
43 * @param changes The set of changes to apply.
44 * @param packageJsonPath The path to the `package.json` file that needs to be updated.
45 * @param parsedJson A pre-existing, in-memory representation of the `package.json` file that
46 * needs to be updated as well.
47 */
48 writeChanges(changes: PackageJsonChange[], packageJsonPath: AbsoluteFsPath, parsedJson?: JsonObject): void;
49}
50/**
51 * A utility class providing a fluent API for recording multiple changes to a `package.json` file
52 * (and optionally its in-memory parsed representation).
53 *
54 * NOTE: This class should generally not be instantiated directly; instances are implicitly created
55 * via `PackageJsonUpdater#createUpdate()`.
56 */
57export declare class PackageJsonUpdate {
58 private writeChangesImpl;
59 private changes;
60 private applied;
61 constructor(writeChangesImpl: WritePackageJsonChangesFn);
62 /**
63 * Record a change to a `package.json` property.
64 *
65 * If the ancestor objects do not yet exist in the `package.json` file, they will be created. The
66 * positioning of the property can also be specified. (If the property already exists, it will be
67 * moved accordingly.)
68 *
69 * NOTE: Property positioning is only guaranteed to be respected in the serialized `package.json`
70 * file. Positioning will not be taken into account when updating in-memory representations.
71 *
72 * NOTE 2: Property positioning only affects the last property in `propertyPath`. Ancestor
73 * objects' positioning will not be affected.
74 *
75 * @param propertyPath The path of a (possibly nested) property to add/update.
76 * @param value The new value to set the property to.
77 * @param position The desired position for the added/updated property.
78 */
79 addChange(propertyPath: string[], value: JsonValue, positioning?: PackageJsonPropertyPositioning): this;
80 /**
81 * Write the recorded changes to the associated `package.json` file (and optionally a
82 * pre-existing, in-memory representation of it).
83 *
84 * @param packageJsonPath The path to the `package.json` file that needs to be updated.
85 * @param parsedJson A pre-existing, in-memory representation of the `package.json` file that
86 * needs to be updated as well.
87 */
88 writeChanges(packageJsonPath: AbsoluteFsPath, parsedJson?: JsonObject): void;
89 private ensureNotApplied;
90}
91/** A `PackageJsonUpdater` that writes directly to the file-system. */
92export declare class DirectPackageJsonUpdater implements PackageJsonUpdater {
93 private fs;
94 constructor(fs: FileSystem);
95 createUpdate(): PackageJsonUpdate;
96 writeChanges(changes: PackageJsonChange[], packageJsonPath: AbsoluteFsPath, preExistingParsedJson?: JsonObject): void;
97}
98export declare function applyChange(ctx: JsonObject, propPath: string[], value: JsonValue, positioning: PackageJsonPropertyPositioning): void;
Note: See TracBrowser for help on using the repository browser.