Primeiro commit do projeto Angular

This commit is contained in:
2026-03-14 20:41:55 +00:00
parent 9bebe1de72
commit 94f4f46395
22413 changed files with 3221690 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
/**
* @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.dev/license
*/
import { logging } from '../src';
export interface ProcessOutput {
write(buffer: string | Buffer): boolean;
}
/**
* A Logger that sends information to STDOUT and STDERR.
*/
export declare function createConsoleLogger(verbose?: boolean, stdout?: ProcessOutput, stderr?: ProcessOutput, colors?: Partial<Record<logging.LogLevel, (s: string) => string>>): logging.Logger;
+58
View File
@@ -0,0 +1,58 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConsoleLogger = createConsoleLogger;
const rxjs_1 = require("rxjs");
const src_1 = require("../src");
/**
* A Logger that sends information to STDOUT and STDERR.
*/
function createConsoleLogger(verbose = false, stdout = process.stdout, stderr = process.stderr, colors) {
const logger = new src_1.logging.IndentLogger('cling');
logger.pipe((0, rxjs_1.filter)((entry) => entry.level !== 'debug' || verbose)).subscribe((entry) => {
const color = colors && colors[entry.level];
let output = stdout;
switch (entry.level) {
case 'warn':
case 'fatal':
case 'error':
output = stderr;
break;
}
// If we do console.log(message) or process.stdout.write(message + '\n'), the process might
// stop before the whole message is written and the stream is flushed. This happens when
// streams are asynchronous.
//
// NodeJS IO streams are different depending on platform and usage. In POSIX environment,
// for example, they're asynchronous when writing to a pipe, but synchronous when writing
// to a TTY. In windows, it's the other way around. You can verify which is which with
// stream.isTTY and platform, but this is not good enough.
// In the async case, one should wait for the callback before sending more data or
// continuing the process. In our case it would be rather hard to do (but not impossible).
//
// Instead we take the easy way out and simply chunk the message and call the write
// function while the buffer drain itself asynchronously. With a smaller chunk size than
// the buffer, we are mostly certain that it works. In this case, the chunk has been picked
// as half a page size (4096/2 = 2048), minus some bytes for the color formatting.
// On POSIX it seems the buffer is 2 pages (8192), but just to be sure (could be different
// by platform).
//
// For more details, see https://nodejs.org/api/process.html#process_a_note_on_process_i_o
const chunkSize = 2000; // Small chunk.
let message = entry.message;
while (message) {
const chunk = message.slice(0, chunkSize);
message = message.slice(chunkSize);
output.write(color ? color(chunk) : chunk);
}
output.write('\n');
});
return logger;
}
//# sourceMappingURL=cli-logger.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"cli-logger.js","sourceRoot":"","sources":["cli-logger.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAYH,kDAkDC;AA5DD,+BAA8B;AAC9B,gCAAiC;AAMjC;;GAEG;AACH,SAAgB,mBAAmB,CACjC,OAAO,GAAG,KAAK,EACf,SAAwB,OAAO,CAAC,MAAM,EACtC,SAAwB,OAAO,CAAC,MAAM,EACtC,MAAiE;IAEjE,MAAM,MAAM,GAAG,IAAI,aAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAEjD,MAAM,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACrF,MAAM,KAAK,GAAG,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,MAAM,GAAG,MAAM,CAAC;QAEpB,QAAQ,KAAK,CAAC,KAAK,EAAE,CAAC;YACpB,KAAK,MAAM,CAAC;YACZ,KAAK,OAAO,CAAC;YACb,KAAK,OAAO;gBACV,MAAM,GAAG,MAAM,CAAC;gBAChB,MAAM;QACV,CAAC;QAED,2FAA2F;QAC3F,wFAAwF;QACxF,4BAA4B;QAC5B,EAAE;QACF,yFAAyF;QACzF,yFAAyF;QACzF,sFAAsF;QACtF,0DAA0D;QAC1D,kFAAkF;QAClF,0FAA0F;QAC1F,EAAE;QACF,mFAAmF;QACnF,wFAAwF;QACxF,2FAA2F;QAC3F,kFAAkF;QAClF,0FAA0F;QAC1F,gBAAgB;QAChB,EAAE;QACF,0FAA0F;QAC1F,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,eAAe;QACvC,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC5B,OAAO,OAAO,EAAE,CAAC;YACf,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YAC1C,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACnC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
+43
View File
@@ -0,0 +1,43 @@
/**
* @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.dev/license
*/
import { Stats } from 'node:fs';
import { Observable } from 'rxjs';
import { Path, PathFragment, virtualFs } from '../src';
/**
* An implementation of the Virtual FS using Node as the background. There are two versions; one
* synchronous and one asynchronous.
*/
export declare class NodeJsAsyncHost implements virtualFs.Host<Stats> {
get capabilities(): virtualFs.HostCapabilities;
write(path: Path, content: virtualFs.FileBuffer): Observable<void>;
read(path: Path): Observable<virtualFs.FileBuffer>;
delete(path: Path): Observable<void>;
rename(from: Path, to: Path): Observable<void>;
list(path: Path): Observable<PathFragment[]>;
exists(path: Path): Observable<boolean>;
isDirectory(path: Path): Observable<boolean>;
isFile(path: Path): Observable<boolean>;
stat(path: Path): Observable<virtualFs.Stats<Stats>>;
watch(path: Path, _options?: virtualFs.HostWatchOptions): Observable<virtualFs.HostWatchEvent> | null;
}
/**
* An implementation of the Virtual FS using Node as the backend, synchronously.
*/
export declare class NodeJsSyncHost implements virtualFs.Host<Stats> {
get capabilities(): virtualFs.HostCapabilities;
write(path: Path, content: virtualFs.FileBuffer): Observable<void>;
read(path: Path): Observable<virtualFs.FileBuffer>;
delete(path: Path): Observable<void>;
rename(from: Path, to: Path): Observable<void>;
list(path: Path): Observable<PathFragment[]>;
exists(path: Path): Observable<boolean>;
isDirectory(path: Path): Observable<boolean>;
isFile(path: Path): Observable<boolean>;
stat(path: Path): Observable<virtualFs.Stats<Stats>>;
watch(path: Path, _options?: virtualFs.HostWatchOptions): Observable<virtualFs.HostWatchEvent> | null;
}
+211
View File
@@ -0,0 +1,211 @@
"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.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeJsSyncHost = exports.NodeJsAsyncHost = void 0;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const rxjs_1 = require("rxjs");
const src_1 = require("../src");
async function exists(path) {
try {
await node_fs_1.promises.access(path, node_fs_1.constants.F_OK);
return true;
}
catch {
return false;
}
}
// This will only be initialized if the watch() method is called.
// Otherwise chokidar appears only in type positions, and shouldn't be referenced
// in the JavaScript output.
let FSWatcher;
function loadFSWatcher() {
if (!FSWatcher) {
try {
FSWatcher = require('chokidar').FSWatcher;
}
catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw new Error('As of angular-devkit version 8.0, the "chokidar" package ' +
'must be installed in order to use watch() features.');
}
throw e;
}
}
}
/**
* An implementation of the Virtual FS using Node as the background. There are two versions; one
* synchronous and one asynchronous.
*/
class NodeJsAsyncHost {
get capabilities() {
return { synchronous: false };
}
write(path, content) {
return (0, rxjs_1.from)(node_fs_1.promises.mkdir((0, src_1.getSystemPath)((0, src_1.dirname)(path)), { recursive: true })).pipe((0, rxjs_1.mergeMap)(() => node_fs_1.promises.writeFile((0, src_1.getSystemPath)(path), new Uint8Array(content))));
}
read(path) {
return (0, rxjs_1.from)(node_fs_1.promises.readFile((0, src_1.getSystemPath)(path))).pipe((0, rxjs_1.map)((buffer) => new Uint8Array(buffer).buffer));
}
delete(path) {
return (0, rxjs_1.from)(node_fs_1.promises.rm((0, src_1.getSystemPath)(path), { force: true, recursive: true, maxRetries: 3 }));
}
rename(from, to) {
return (0, rxjs_1.from)(node_fs_1.promises.rename((0, src_1.getSystemPath)(from), (0, src_1.getSystemPath)(to)));
}
list(path) {
return (0, rxjs_1.from)(node_fs_1.promises.readdir((0, src_1.getSystemPath)(path))).pipe((0, rxjs_1.map)((names) => names.map((name) => (0, src_1.fragment)(name))));
}
exists(path) {
return (0, rxjs_1.from)(exists((0, src_1.getSystemPath)(path)));
}
isDirectory(path) {
return this.stat(path).pipe((0, rxjs_1.map)((stat) => stat.isDirectory()));
}
isFile(path) {
return this.stat(path).pipe((0, rxjs_1.map)((stat) => stat.isFile()));
}
// Some hosts may not support stat.
stat(path) {
return (0, rxjs_1.from)(node_fs_1.promises.stat((0, src_1.getSystemPath)(path)));
}
// Some hosts may not support watching.
watch(path, _options) {
return new rxjs_1.Observable((obs) => {
loadFSWatcher();
const watcher = new FSWatcher({ persistent: true });
watcher.add((0, src_1.getSystemPath)(path));
watcher
.on('change', (path) => {
obs.next({
path: (0, src_1.normalize)(path),
time: new Date(),
type: src_1.virtualFs.HostWatchEventType.Changed,
});
})
.on('add', (path) => {
obs.next({
path: (0, src_1.normalize)(path),
time: new Date(),
type: src_1.virtualFs.HostWatchEventType.Created,
});
})
.on('unlink', (path) => {
obs.next({
path: (0, src_1.normalize)(path),
time: new Date(),
type: src_1.virtualFs.HostWatchEventType.Deleted,
});
});
return () => {
void watcher.close();
};
}).pipe((0, rxjs_1.publish)(), (0, rxjs_1.refCount)());
}
}
exports.NodeJsAsyncHost = NodeJsAsyncHost;
/**
* An implementation of the Virtual FS using Node as the backend, synchronously.
*/
class NodeJsSyncHost {
get capabilities() {
return { synchronous: true };
}
write(path, content) {
return new rxjs_1.Observable((obs) => {
(0, node_fs_1.mkdirSync)((0, src_1.getSystemPath)((0, src_1.dirname)(path)), { recursive: true });
(0, node_fs_1.writeFileSync)((0, src_1.getSystemPath)(path), new Uint8Array(content));
obs.next();
obs.complete();
});
}
read(path) {
return new rxjs_1.Observable((obs) => {
const buffer = (0, node_fs_1.readFileSync)((0, src_1.getSystemPath)(path));
obs.next(new Uint8Array(buffer).buffer);
obs.complete();
});
}
delete(path) {
return new rxjs_1.Observable((obs) => {
(0, node_fs_1.rmSync)((0, src_1.getSystemPath)(path), { force: true, recursive: true, maxRetries: 3 });
obs.complete();
});
}
rename(from, to) {
return new rxjs_1.Observable((obs) => {
const toSystemPath = (0, src_1.getSystemPath)(to);
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(toSystemPath), { recursive: true });
(0, node_fs_1.renameSync)((0, src_1.getSystemPath)(from), toSystemPath);
obs.next();
obs.complete();
});
}
list(path) {
return new rxjs_1.Observable((obs) => {
const names = (0, node_fs_1.readdirSync)((0, src_1.getSystemPath)(path));
obs.next(names.map((name) => (0, src_1.fragment)(name)));
obs.complete();
});
}
exists(path) {
return new rxjs_1.Observable((obs) => {
obs.next((0, node_fs_1.existsSync)((0, src_1.getSystemPath)(path)));
obs.complete();
});
}
isDirectory(path) {
return this.stat(path).pipe((0, rxjs_1.map)((stat) => stat.isDirectory()));
}
isFile(path) {
return this.stat(path).pipe((0, rxjs_1.map)((stat) => stat.isFile()));
}
// Some hosts may not support stat.
stat(path) {
return new rxjs_1.Observable((obs) => {
obs.next((0, node_fs_1.statSync)((0, src_1.getSystemPath)(path)));
obs.complete();
});
}
// Some hosts may not support watching.
watch(path, _options) {
return new rxjs_1.Observable((obs) => {
loadFSWatcher();
const watcher = new FSWatcher({ persistent: false });
watcher.add((0, src_1.getSystemPath)(path));
watcher
.on('change', (path) => {
obs.next({
path: (0, src_1.normalize)(path),
time: new Date(),
type: src_1.virtualFs.HostWatchEventType.Changed,
});
})
.on('add', (path) => {
obs.next({
path: (0, src_1.normalize)(path),
time: new Date(),
type: src_1.virtualFs.HostWatchEventType.Created,
});
})
.on('unlink', (path) => {
obs.next({
path: (0, src_1.normalize)(path),
time: new Date(),
type: src_1.virtualFs.HostWatchEventType.Deleted,
});
});
return () => {
void watcher.close();
};
}).pipe((0, rxjs_1.publish)(), (0, rxjs_1.refCount)());
}
}
exports.NodeJsSyncHost = NodeJsSyncHost;
//# sourceMappingURL=host.js.map
File diff suppressed because one or more lines are too long
+9
View File
@@ -0,0 +1,9 @@
/**
* @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.dev/license
*/
export * from './cli-logger';
export * from './host';
+26
View File
@@ -0,0 +1,26 @@
"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.dev/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 __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./cli-logger"), exports);
__exportStar(require("./host"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,yCAAuB"}
+20
View File
@@ -0,0 +1,20 @@
/**
* @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.dev/license
*/
import * as fs from 'node:fs';
import { Path, virtualFs } from '../../src';
/**
* A Sync Scoped Host that creates a temporary directory and scope to it.
*/
export declare class TempScopedNodeJsSyncHost extends virtualFs.ScopedHost<fs.Stats> {
protected _sync?: virtualFs.SyncDelegateHost<fs.Stats>;
protected _root: Path;
constructor();
get files(): Path[];
get root(): Path;
get sync(): virtualFs.SyncDelegateHost<fs.Stats>;
}
+90
View File
@@ -0,0 +1,90 @@
"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.dev/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 () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TempScopedNodeJsSyncHost = void 0;
const crypto = __importStar(require("node:crypto"));
const fs = __importStar(require("node:fs"));
const os = __importStar(require("node:os"));
const path = __importStar(require("node:path"));
const src_1 = require("../../src");
const host_1 = require("../host");
/**
* A Sync Scoped Host that creates a temporary directory and scope to it.
*/
class TempScopedNodeJsSyncHost extends src_1.virtualFs.ScopedHost {
_sync;
_root;
constructor() {
const root = (0, src_1.normalize)(path.join(os.tmpdir(), `devkit-host-${crypto.randomUUID()}-${process.pid}`));
fs.mkdirSync((0, src_1.getSystemPath)(root));
super(new host_1.NodeJsSyncHost(), root);
this._root = root;
}
get files() {
const sync = this.sync;
function _visit(p) {
return sync
.list(p)
.map((fragment) => (0, src_1.join)(p, fragment))
.reduce((files, path) => {
if (sync.isDirectory(path)) {
return files.concat(_visit(path));
}
else {
return files.concat(path);
}
}, []);
}
return _visit((0, src_1.normalize)('/'));
}
get root() {
return this._root;
}
get sync() {
if (!this._sync) {
this._sync = new src_1.virtualFs.SyncDelegateHost(this);
}
return this._sync;
}
}
exports.TempScopedNodeJsSyncHost = TempScopedNodeJsSyncHost;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAClC,mCAA4E;AAC5E,kCAAyC;AAEzC;;GAEG;AACH,MAAa,wBAAyB,SAAQ,eAAS,CAAC,UAAoB;IAChE,KAAK,CAAwC;IACpC,KAAK,CAAO;IAE/B;QACE,MAAM,IAAI,GAAG,IAAA,eAAS,EACpB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,MAAM,CAAC,UAAU,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAC5E,CAAC;QACF,EAAE,CAAC,SAAS,CAAC,IAAA,mBAAa,EAAC,IAAI,CAAC,CAAC,CAAC;QAElC,KAAK,CAAC,IAAI,qBAAc,EAAE,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,IAAI,KAAK;QACP,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,SAAS,MAAM,CAAC,CAAO;YACrB,OAAO,IAAI;iBACR,IAAI,CAAC,CAAC,CAAC;iBACP,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAA,UAAI,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;iBACpC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;gBACtB,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBACpC,CAAC;qBAAM,CAAC;oBACN,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC,EAAE,EAAY,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,MAAM,CAAC,IAAA,eAAS,EAAC,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,IAAI,eAAS,CAAC,gBAAgB,CAAW,IAAI,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AA1CD,4DA0CC"}