@depup/angular-devkit__architect 0.2102.2-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/bin/architect.d.ts +9 -0
  4. package/bin/architect.js +252 -0
  5. package/bin/architect.js.map +1 -0
  6. package/bin/cli.js +10 -0
  7. package/builders/all-of.d.ts +11 -0
  8. package/builders/all-of.js +49 -0
  9. package/builders/all-of.js.map +1 -0
  10. package/builders/builders.json +25 -0
  11. package/builders/concat.d.ts +11 -0
  12. package/builders/concat.js +46 -0
  13. package/builders/concat.js.map +1 -0
  14. package/builders/false.d.ts +10 -0
  15. package/builders/false.js +16 -0
  16. package/builders/false.js.map +1 -0
  17. package/builders/noop-schema.json +4 -0
  18. package/builders/operator-schema.d.ts +22 -0
  19. package/builders/operator-schema.js +5 -0
  20. package/builders/operator-schema.js.map +1 -0
  21. package/builders/operator-schema.json +41 -0
  22. package/builders/true.d.ts +10 -0
  23. package/builders/true.js +13 -0
  24. package/builders/true.js.map +1 -0
  25. package/changes.json +5 -0
  26. package/index.d.ts +8 -0
  27. package/index.js +25 -0
  28. package/index.js.map +1 -0
  29. package/node/index.d.ts +10 -0
  30. package/node/index.js +50 -0
  31. package/node/index.js.map +1 -0
  32. package/node/jobs/job-registry.d.ts +20 -0
  33. package/node/jobs/job-registry.js +60 -0
  34. package/node/jobs/job-registry.js.map +1 -0
  35. package/node/node-modules-architect-host.d.ts +41 -0
  36. package/node/node-modules-architect-host.js +242 -0
  37. package/node/node-modules-architect-host.js.map +1 -0
  38. package/package.json +51 -0
  39. package/src/api.d.ts +269 -0
  40. package/src/api.js +98 -0
  41. package/src/api.js.map +1 -0
  42. package/src/architect.d.ts +25 -0
  43. package/src/architect.js +268 -0
  44. package/src/architect.js.map +1 -0
  45. package/src/builders-schema.d.ts +33 -0
  46. package/src/builders-schema.js +5 -0
  47. package/src/builders-schema.js.map +1 -0
  48. package/src/builders-schema.json +70 -0
  49. package/src/create-builder.d.ts +12 -0
  50. package/src/create-builder.js +184 -0
  51. package/src/create-builder.js.map +1 -0
  52. package/src/index.d.ts +12 -0
  53. package/src/index.js +54 -0
  54. package/src/index.js.map +1 -0
  55. package/src/input-schema.d.ts +19 -0
  56. package/src/input-schema.js +5 -0
  57. package/src/input-schema.js.map +1 -0
  58. package/src/input-schema.json +39 -0
  59. package/src/internal.d.ts +68 -0
  60. package/src/internal.js +27 -0
  61. package/src/internal.js.map +1 -0
  62. package/src/jobs/api.d.ts +332 -0
  63. package/src/jobs/api.js +74 -0
  64. package/src/jobs/api.js.map +1 -0
  65. package/src/jobs/create-job-handler.d.ts +47 -0
  66. package/src/jobs/create-job-handler.js +146 -0
  67. package/src/jobs/create-job-handler.js.map +1 -0
  68. package/src/jobs/dispatcher.d.ts +31 -0
  69. package/src/jobs/dispatcher.js +50 -0
  70. package/src/jobs/dispatcher.js.map +1 -0
  71. package/src/jobs/exception.d.ts +15 -0
  72. package/src/jobs/exception.js +24 -0
  73. package/src/jobs/exception.js.map +1 -0
  74. package/src/jobs/fallback-registry.d.ts +19 -0
  75. package/src/jobs/fallback-registry.js +28 -0
  76. package/src/jobs/fallback-registry.js.map +1 -0
  77. package/src/jobs/index.d.ts +16 -0
  78. package/src/jobs/index.js +56 -0
  79. package/src/jobs/index.js.map +1 -0
  80. package/src/jobs/simple-registry.d.ts +44 -0
  81. package/src/jobs/simple-registry.js +76 -0
  82. package/src/jobs/simple-registry.js.map +1 -0
  83. package/src/jobs/simple-scheduler.d.ts +77 -0
  84. package/src/jobs/simple-scheduler.js +395 -0
  85. package/src/jobs/simple-scheduler.js.map +1 -0
  86. package/src/jobs/strategy.d.ts +26 -0
  87. package/src/jobs/strategy.js +94 -0
  88. package/src/jobs/strategy.js.map +1 -0
  89. package/src/jobs/types.d.ts +15 -0
  90. package/src/jobs/types.js +10 -0
  91. package/src/jobs/types.js.map +1 -0
  92. package/src/options.d.ts +12 -0
  93. package/src/options.js +30 -0
  94. package/src/options.js.map +1 -0
  95. package/src/output-schema.d.ts +15 -0
  96. package/src/output-schema.js +5 -0
  97. package/src/output-schema.js.map +1 -0
  98. package/src/output-schema.json +33 -0
  99. package/src/progress-schema.d.ts +21 -0
  100. package/src/progress-schema.js +13 -0
  101. package/src/progress-schema.js.map +1 -0
  102. package/src/progress-schema.json +83 -0
  103. package/src/schedule-by-name.d.ts +23 -0
  104. package/src/schedule-by-name.js +101 -0
  105. package/src/schedule-by-name.js.map +1 -0
  106. package/src/targets-schema.json +39 -0
  107. package/testing/index.d.ts +9 -0
  108. package/testing/index.js +26 -0
  109. package/testing/index.js.map +1 -0
  110. package/testing/test-project-host.d.ts +32 -0
  111. package/testing/test-project-host.js +110 -0
  112. package/testing/test-project-host.js.map +1 -0
  113. package/testing/testing-architect-host.d.ts +42 -0
  114. package/testing/testing-architect-host.js +135 -0
  115. package/testing/testing-architect-host.js.map +1 -0
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "BuilderOutputSchema",
4
+ "title": "Output schema for builders.",
5
+ "type": "object",
6
+ "properties": {
7
+ "success": {
8
+ "type": "boolean"
9
+ },
10
+ "error": {
11
+ "type": "string"
12
+ },
13
+ "target": {
14
+ "type": "object",
15
+ "properties": {
16
+ "project": {
17
+ "type": "string"
18
+ },
19
+ "target": {
20
+ "type": "string"
21
+ },
22
+ "configuration": {
23
+ "type": "string"
24
+ }
25
+ }
26
+ },
27
+ "info": {
28
+ "type": "object"
29
+ }
30
+ },
31
+ "additionalProperties": true,
32
+ "required": ["success"]
33
+ }
@@ -0,0 +1,21 @@
1
+ export type Schema = {
2
+ builder: {
3
+ [key: string]: any;
4
+ };
5
+ current?: number;
6
+ error?: any;
7
+ id: number;
8
+ state: State;
9
+ status?: string;
10
+ target?: {
11
+ [key: string]: any;
12
+ };
13
+ total?: number;
14
+ [property: string]: any;
15
+ };
16
+ export declare enum State {
17
+ Error = "error",
18
+ Running = "running",
19
+ Stopped = "stopped",
20
+ Waiting = "waiting"
21
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
3
+ // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.State = void 0;
6
+ var State;
7
+ (function (State) {
8
+ State["Error"] = "error";
9
+ State["Running"] = "running";
10
+ State["Stopped"] = "stopped";
11
+ State["Waiting"] = "waiting";
12
+ })(State || (exports.State = State = {}));
13
+ //# sourceMappingURL=progress-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-schema.js","sourceRoot":"","sources":["progress-schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF;;;AAcpF,IAAY,KAKX;AALD,WAAY,KAAK;IACb,wBAAe,CAAA;IACf,4BAAmB,CAAA;IACnB,4BAAmB,CAAA;IACnB,4BAAmB,CAAA;AACvB,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB"}
@@ -0,0 +1,83 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "BuilderProgressSchema",
4
+ "title": "Progress schema for builders.",
5
+ "type": "object",
6
+ "allOf": [
7
+ {
8
+ "type": "object",
9
+ "oneOf": [
10
+ {
11
+ "type": "object",
12
+ "properties": {
13
+ "state": {
14
+ "type": "string",
15
+ "enum": ["stopped"]
16
+ }
17
+ },
18
+ "required": ["state"]
19
+ },
20
+ {
21
+ "type": "object",
22
+ "properties": {
23
+ "state": {
24
+ "type": "string",
25
+ "enum": ["waiting"]
26
+ },
27
+ "status": {
28
+ "type": "string"
29
+ }
30
+ },
31
+ "required": ["state"]
32
+ },
33
+ {
34
+ "type": "object",
35
+ "properties": {
36
+ "state": {
37
+ "type": "string",
38
+ "enum": ["running"]
39
+ },
40
+ "current": {
41
+ "type": "number",
42
+ "minimum": 0
43
+ },
44
+ "total": {
45
+ "type": "number",
46
+ "minimum": 0
47
+ },
48
+ "status": {
49
+ "type": "string"
50
+ }
51
+ },
52
+ "required": ["state"]
53
+ },
54
+ {
55
+ "type": "object",
56
+ "properties": {
57
+ "state": {
58
+ "type": "string",
59
+ "enum": ["error"]
60
+ },
61
+ "error": true
62
+ },
63
+ "required": ["state"]
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "type": "object",
69
+ "properties": {
70
+ "builder": {
71
+ "type": "object"
72
+ },
73
+ "target": {
74
+ "type": "object"
75
+ },
76
+ "id": {
77
+ "type": "number"
78
+ }
79
+ },
80
+ "required": ["builder", "id"]
81
+ }
82
+ ]
83
+ }
@@ -0,0 +1,23 @@
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.dev/license
7
+ */
8
+ import { json, logging } from '@angular-devkit/core';
9
+ import { BuilderRun, Target } from './api';
10
+ import { Scheduler } from './jobs';
11
+ export declare function scheduleByName(name: string, buildOptions: json.JsonObject, options: {
12
+ target?: Target;
13
+ scheduler: Scheduler;
14
+ logger: logging.LoggerApi;
15
+ workspaceRoot: string | Promise<string>;
16
+ currentDirectory: string | Promise<string>;
17
+ }): Promise<BuilderRun>;
18
+ export declare function scheduleByTarget(target: Target, overrides: json.JsonObject, options: {
19
+ scheduler: Scheduler;
20
+ logger: logging.LoggerApi;
21
+ workspaceRoot: string | Promise<string>;
22
+ currentDirectory: string | Promise<string>;
23
+ }): Promise<BuilderRun>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.scheduleByName = scheduleByName;
11
+ exports.scheduleByTarget = scheduleByTarget;
12
+ const rxjs_1 = require("rxjs");
13
+ const api_1 = require("./api");
14
+ const jobs_1 = require("./jobs");
15
+ const progressSchema = require('./progress-schema.json');
16
+ let _uniqueId = 0;
17
+ async function scheduleByName(name, buildOptions, options) {
18
+ const childLoggerName = options.target ? `{${(0, api_1.targetStringFromTarget)(options.target)}}` : name;
19
+ const logger = options.logger.createChild(childLoggerName);
20
+ const job = options.scheduler.schedule(name, {});
21
+ let stateSubscription;
22
+ const workspaceRoot = await options.workspaceRoot;
23
+ const currentDirectory = await options.currentDirectory;
24
+ const description = await (0, rxjs_1.firstValueFrom)(job.description);
25
+ const info = description.info;
26
+ const id = ++_uniqueId;
27
+ const message = {
28
+ id,
29
+ currentDirectory,
30
+ workspaceRoot,
31
+ info: info,
32
+ options: buildOptions,
33
+ ...(options.target ? { target: options.target } : {}),
34
+ };
35
+ // Wait for the job to be ready.
36
+ if (job.state !== jobs_1.JobState.Started) {
37
+ stateSubscription = job.outboundBus.subscribe({
38
+ next: (event) => {
39
+ if (event.kind === jobs_1.JobOutboundMessageKind.Start) {
40
+ job.input.next(message);
41
+ }
42
+ },
43
+ error: () => { },
44
+ });
45
+ }
46
+ else {
47
+ job.input.next(message);
48
+ }
49
+ const logChannelSub = job.getChannel('log').subscribe({
50
+ next: (entry) => {
51
+ logger.next(entry);
52
+ },
53
+ error: () => { },
54
+ });
55
+ const outboundBusSub = job.outboundBus.subscribe({
56
+ error() { },
57
+ complete() {
58
+ outboundBusSub.unsubscribe();
59
+ logChannelSub.unsubscribe();
60
+ stateSubscription.unsubscribe();
61
+ },
62
+ });
63
+ const output = job.output.pipe((0, rxjs_1.map)((output) => ({
64
+ ...output,
65
+ ...(options.target ? { target: options.target } : 0),
66
+ info,
67
+ })), (0, rxjs_1.shareReplay)());
68
+ // Start the builder.
69
+ output.pipe((0, rxjs_1.first)()).subscribe({
70
+ error: () => { },
71
+ });
72
+ return {
73
+ id,
74
+ info,
75
+ // This is a getter so that it always returns the next output, and not the same one.
76
+ get result() {
77
+ return (0, rxjs_1.firstValueFrom)(output);
78
+ },
79
+ get lastOutput() {
80
+ return (0, rxjs_1.lastValueFrom)(output);
81
+ },
82
+ output,
83
+ progress: job
84
+ .getChannel('progress', progressSchema)
85
+ .pipe((0, rxjs_1.shareReplay)(1)),
86
+ stop() {
87
+ job.stop();
88
+ return job.outboundBus
89
+ .pipe((0, rxjs_1.ignoreElements)(), (0, rxjs_1.catchError)(() => rxjs_1.EMPTY))
90
+ .toPromise();
91
+ },
92
+ };
93
+ }
94
+ async function scheduleByTarget(target, overrides, options) {
95
+ return scheduleByName(`{${(0, api_1.targetStringFromTarget)(target)}}`, overrides, {
96
+ ...options,
97
+ target,
98
+ logger: options.logger,
99
+ });
100
+ }
101
+ //# sourceMappingURL=schedule-by-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule-by-name.js","sourceRoot":"","sources":["schedule-by-name.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA6BH,wCAuGC;AAED,4CAeC;AAlJD,+BAUc;AACd,+BAQe;AACf,iCAAqE;AAErE,MAAM,cAAc,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAEzD,IAAI,SAAS,GAAG,CAAC,CAAC;AAEX,KAAK,UAAU,cAAc,CAClC,IAAY,EACZ,YAA6B,EAC7B,OAMC;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAA,4BAAsB,EAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9F,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAC3D,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAkC,IAAI,EAAE,EAAE,CAAC,CAAC;IAClF,IAAI,iBAA+B,CAAC;IAEpC,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC;IA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,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,SAA0B,EAC1B,OAKC;IAED,OAAO,cAAc,CAAC,IAAI,IAAA,4BAAsB,EAAC,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE;QACtE,GAAG,OAAO;QACV,MAAM;QACN,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "ArchitectTargets",
4
+ "title": "Targets schema for validating Architect targets configuration.",
5
+ "type": "object",
6
+ "description": "A map of available project targets.",
7
+ "additionalProperties": {
8
+ "$ref": "#/definitions/target"
9
+ },
10
+ "required": [],
11
+ "definitions": {
12
+ "target": {
13
+ "type": "object",
14
+ "description": "Target options.",
15
+ "properties": {
16
+ "builder": {
17
+ "type": "string",
18
+ "description": "The builder used for this package."
19
+ },
20
+ "options": {
21
+ "$ref": "#/definitions/options"
22
+ },
23
+ "configurations": {
24
+ "type": "object",
25
+ "description": "A map of alternative target options.",
26
+ "additionalProperties": {
27
+ "$ref": "#/definitions/options"
28
+ }
29
+ }
30
+ },
31
+ "additionalProperties": false,
32
+ "required": ["builder", "options"]
33
+ },
34
+ "options": {
35
+ "type": "object",
36
+ "description": "Target options."
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,9 @@
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.dev/license
7
+ */
8
+ export * from './testing-architect-host';
9
+ export * from './test-project-host';
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ __exportStar(require("./testing-architect-host"), exports);
25
+ __exportStar(require("./test-project-host"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,2DAAyC;AACzC,sDAAoC"}
@@ -0,0 +1,32 @@
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.dev/license
7
+ */
8
+ import { Path, PathFragment, virtualFs } from '@angular-devkit/core';
9
+ import { NodeJsSyncHost } from '@angular-devkit/core/node';
10
+ import { Stats } from 'node:fs';
11
+ import { Observable } from 'rxjs';
12
+ /**
13
+ * @deprecated
14
+ */
15
+ export declare class TestProjectHost extends NodeJsSyncHost {
16
+ protected _templateRoot: Path;
17
+ private _currentRoot;
18
+ private _scopedSyncHost;
19
+ constructor(_templateRoot: Path);
20
+ root(): Path;
21
+ scopedSync(): virtualFs.SyncDelegateHost<Stats>;
22
+ initialize(): Observable<void>;
23
+ restore(): Observable<void>;
24
+ writeMultipleFiles(files: {
25
+ [path: string]: string | ArrayBufferLike | Buffer;
26
+ }): void;
27
+ replaceInFile(path: string, match: RegExp | string, replacement: string): void;
28
+ appendToFile(path: string, str: string): void;
29
+ fileMatchExists(dir: string, regex: RegExp): PathFragment | undefined;
30
+ copyFile(from: string, to: string): void;
31
+ private findUniqueFolderPath;
32
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.TestProjectHost = void 0;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const node_1 = require("@angular-devkit/core/node");
13
+ const rxjs_1 = require("rxjs");
14
+ /**
15
+ * @deprecated
16
+ */
17
+ class TestProjectHost extends node_1.NodeJsSyncHost {
18
+ _templateRoot;
19
+ _currentRoot = null;
20
+ _scopedSyncHost = null;
21
+ constructor(_templateRoot) {
22
+ super();
23
+ this._templateRoot = _templateRoot;
24
+ }
25
+ root() {
26
+ if (this._currentRoot === null) {
27
+ throw new Error('TestProjectHost must be initialized before being used.');
28
+ }
29
+ return this._currentRoot;
30
+ }
31
+ scopedSync() {
32
+ if (this._currentRoot === null || this._scopedSyncHost === null) {
33
+ throw new Error('TestProjectHost must be initialized before being used.');
34
+ }
35
+ return this._scopedSyncHost;
36
+ }
37
+ initialize() {
38
+ const recursiveList = (path) => this.list(path).pipe(
39
+ // Emit each fragment individually.
40
+ (0, rxjs_1.concatMap)((fragments) => (0, rxjs_1.from)(fragments)),
41
+ // Join the path with fragment.
42
+ (0, rxjs_1.map)((fragment) => (0, core_1.join)(path, fragment)),
43
+ // Emit directory content paths instead of the directory path.
44
+ (0, rxjs_1.mergeMap)((path) => this.isDirectory(path).pipe((0, rxjs_1.concatMap)((isDir) => (isDir ? recursiveList(path) : (0, rxjs_1.of)(path))))));
45
+ // Find a unique folder that we can write to use as current root.
46
+ return this.findUniqueFolderPath().pipe(
47
+ // Save the path and create a scoped host for it.
48
+ (0, rxjs_1.tap)((newFolderPath) => {
49
+ this._currentRoot = newFolderPath;
50
+ this._scopedSyncHost = new core_1.virtualFs.SyncDelegateHost(new core_1.virtualFs.ScopedHost(this, this.root()));
51
+ }),
52
+ // List all files in root.
53
+ (0, rxjs_1.concatMap)(() => recursiveList(this._templateRoot)),
54
+ // Copy them over to the current root.
55
+ (0, rxjs_1.concatMap)((from) => {
56
+ const to = (0, core_1.join)(this.root(), (0, core_1.relative)(this._templateRoot, from));
57
+ return this.read(from).pipe((0, rxjs_1.concatMap)((buffer) => this.write(to, buffer)));
58
+ }), (0, rxjs_1.map)(() => { }));
59
+ }
60
+ restore() {
61
+ if (this._currentRoot === null) {
62
+ return rxjs_1.EMPTY;
63
+ }
64
+ // Delete the current root and clear the variables.
65
+ // Wait 50ms and retry up to 10 times, to give time for file locks to clear.
66
+ return this.exists(this.root()).pipe((0, rxjs_1.delay)(50), (0, rxjs_1.concatMap)((exists) => (exists ? this.delete(this.root()) : rxjs_1.EMPTY)), (0, rxjs_1.retry)(10), (0, rxjs_1.finalize)(() => {
67
+ this._currentRoot = null;
68
+ this._scopedSyncHost = null;
69
+ }));
70
+ }
71
+ writeMultipleFiles(files) {
72
+ Object.keys(files).forEach((fileName) => {
73
+ let content = files[fileName];
74
+ if (typeof content == 'string') {
75
+ content = core_1.virtualFs.stringToFileBuffer(content);
76
+ }
77
+ else if (content instanceof Buffer) {
78
+ content = content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength);
79
+ }
80
+ this.scopedSync().write((0, core_1.normalize)(fileName), content);
81
+ });
82
+ }
83
+ replaceInFile(path, match, replacement) {
84
+ const content = core_1.virtualFs.fileBufferToString(this.scopedSync().read((0, core_1.normalize)(path)));
85
+ this.scopedSync().write((0, core_1.normalize)(path), core_1.virtualFs.stringToFileBuffer(content.replace(match, replacement)));
86
+ }
87
+ appendToFile(path, str) {
88
+ const content = core_1.virtualFs.fileBufferToString(this.scopedSync().read((0, core_1.normalize)(path)));
89
+ this.scopedSync().write((0, core_1.normalize)(path), core_1.virtualFs.stringToFileBuffer(content.concat(str)));
90
+ }
91
+ fileMatchExists(dir, regex) {
92
+ const [fileName] = this.scopedSync()
93
+ .list((0, core_1.normalize)(dir))
94
+ .filter((name) => name.match(regex));
95
+ return fileName || undefined;
96
+ }
97
+ copyFile(from, to) {
98
+ const content = this.scopedSync().read((0, core_1.normalize)(from));
99
+ this.scopedSync().write((0, core_1.normalize)(to), content);
100
+ }
101
+ findUniqueFolderPath() {
102
+ // 11 character alphanumeric string.
103
+ const randomString = Math.random().toString(36).slice(2);
104
+ const newFolderName = `test-project-host-${(0, core_1.basename)(this._templateRoot)}-${randomString}`;
105
+ const newFolderPath = (0, core_1.join)((0, core_1.dirname)(this._templateRoot), newFolderName);
106
+ return this.exists(newFolderPath).pipe((0, rxjs_1.concatMap)((exists) => (exists ? this.findUniqueFolderPath() : (0, rxjs_1.of)(newFolderPath))));
107
+ }
108
+ }
109
+ exports.TestProjectHost = TestProjectHost;
110
+ //# sourceMappingURL=test-project-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-project-host.js","sourceRoot":"","sources":["test-project-host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+CAS8B;AAC9B,oDAA2D;AAE3D,+BAYc;AAEd;;GAEG;AACH,MAAa,eAAgB,SAAQ,qBAAc;IAI3B;IAHd,YAAY,GAAgB,IAAI,CAAC;IACjC,eAAe,GAA6C,IAAI,CAAC;IAEzE,YAAsB,aAAmB;QACvC,KAAK,EAAE,CAAC;QADY,kBAAa,GAAb,aAAa,CAAM;IAEzC,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,IAAI,IAAI,CAAC,YAAY,KAAK,IAAI,IAAI,IAAI,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
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.dev/license
7
+ */
8
+ import { json } from '@angular-devkit/core';
9
+ import { BuilderInfo, Target } from '../src';
10
+ import { ArchitectHost, Builder } from '../src/internal';
11
+ export declare class TestingArchitectHost implements ArchitectHost {
12
+ workspaceRoot: string;
13
+ currentDirectory: string;
14
+ private _backendHost;
15
+ private _builderImportMap;
16
+ private _builderMap;
17
+ private _targetMap;
18
+ /**
19
+ * Can provide a backend host, in case of integration tests.
20
+ * @param workspaceRoot The workspace root to use.
21
+ * @param currentDirectory The current directory to use.
22
+ * @param _backendHost A host to defer calls that aren't resolved here.
23
+ */
24
+ constructor(workspaceRoot?: string, currentDirectory?: string, _backendHost?: ArchitectHost | null);
25
+ addBuilder(builderName: string, builder: Builder, description?: string, optionSchema?: json.schema.JsonSchema): void;
26
+ addBuilderFromPackage(packageName: string): Promise<void>;
27
+ addTarget(target: Target, builderName: string, options?: json.JsonObject): void;
28
+ getBuilderNameForTarget(target: Target): Promise<string | null>;
29
+ /**
30
+ * Resolve a builder. This needs to return a string which will be used in a dynamic `import()`
31
+ * clause. This should throw if no builder can be found. The dynamic import will throw if
32
+ * it is unsupported.
33
+ * @param builderName The name of the builder to be used.
34
+ * @returns All the info needed for the builder itself.
35
+ */
36
+ resolveBuilder(builderName: string): Promise<BuilderInfo | null>;
37
+ getCurrentDirectory(): Promise<string>;
38
+ getWorkspaceRoot(): Promise<string>;
39
+ getOptionsForTarget(target: Target): Promise<json.JsonObject | null>;
40
+ getProjectMetadata(target: Target | string): Promise<json.JsonObject | null>;
41
+ loadBuilder(info: BuilderInfo): Promise<Builder | null>;
42
+ }