How to use the @angular-devkit/core.virtualFs function in @angular-devkit/core

To help you get started, we’ve selected a few @angular-devkit/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rxweb / rxweb / rxweb.io / node_modules / @angular-devkit / build-angular / src / dev-server / index.js View on Github external
run(builderConfig) {
        const options = builderConfig.options;
        const root = this.context.workspace.root;
        const projectRoot = core_1.resolve(root, builderConfig.root);
        const host = new core_1.virtualFs.AliasHost(this.context.host);
        const webpackDevServerBuilder = new build_webpack_1.WebpackDevServerBuilder(Object.assign({}, this.context, { host }));
        let browserOptions;
        let first = true;
        let opnAddress;
        return check_port_1.checkPort(options.port, options.host).pipe(operators_1.tap((port) => options.port = port), operators_1.concatMap(() => this._getBrowserOptions(options)), operators_1.tap((opts) => browserOptions = opts), operators_1.concatMap(() => utils_1.normalizeFileReplacements(browserOptions.fileReplacements, host, root)), operators_1.tap(fileReplacements => browserOptions.fileReplacements = fileReplacements), operators_1.concatMap(() => utils_1.normalizeAssetPatterns(browserOptions.assets, host, root, projectRoot, builderConfig.sourceRoot)), 
        // Replace the assets in options with the normalized version.
        operators_1.tap((assetPatternObjects => browserOptions.assets = assetPatternObjects)), operators_1.concatMap(() => {
            const webpackConfig = this.buildWebpackConfig(root, projectRoot, host, browserOptions);
            let webpackDevServerConfig;
            try {
                webpackDevServerConfig = this._buildServerConfig(root, projectRoot, options, browserOptions);
            }
            catch (err) {
                return rxjs_1.throwError(err);
            }
            // Resolve public host and client address.
github johandb / svg-drawing-tool / node_modules / @angular-devkit / build-angular / src / app-shell / index.js View on Github external
})), this.getServerModuleBundlePath(options)).pipe(operators_1.switchMap(([[browserIndexOutputPath, indexContent], serverBundlePath]) => {
            const root = this.context.workspace.root;
            require_project_module_1.requireProjectModule(core_1.getSystemPath(root), 'zone.js/dist/zone-node');
            const renderModuleFactory = require_project_module_1.requireProjectModule(core_1.getSystemPath(root), '@angular/platform-server').renderModuleFactory;
            const AppServerModuleNgFactory = require(core_1.getSystemPath(serverBundlePath)).AppServerModuleNgFactory;
            const indexHtml = core_1.virtualFs.fileBufferToString(indexContent);
            const outputIndexPath = core_1.join(root, options.outputIndexPath || browserIndexOutputPath);
            // Render to HTML and overwrite the client index file.
            return rxjs_1.from(renderModuleFactory(AppServerModuleNgFactory, {
                document: indexHtml,
                url: options.route,
            })
                .then(async (html) => {
                await this.context.host
                    .write(outputIndexPath, core_1.virtualFs.stringToFileBuffer(html))
                    .toPromise();
                if (browserOptions.serviceWorker) {
                    await service_worker_1.augmentAppWithServiceWorker(this.context.host, root, projectRoot, core_1.join(root, browserOptions.outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
                }
                return { success: true };
            }));
        }));
github johandb / svg-drawing-tool / node_modules / @ngtools / webpack / src / type_checker.js View on Github external
constructor(_compilerOptions, _basePath, _JitMode, _rootNames, hostReplacementPaths) {
        this._compilerOptions = _compilerOptions;
        this._JitMode = _JitMode;
        this._rootNames = _rootNames;
        benchmark_1.time('TypeChecker.constructor');
        const host = new core_1.virtualFs.AliasHost(new node_1.NodeJsSyncHost());
        // Add file replacements.
        for (const from in hostReplacementPaths) {
            const normalizedFrom = core_1.resolve(core_1.normalize(_basePath), core_1.normalize(from));
            const normalizedWith = core_1.resolve(core_1.normalize(_basePath), core_1.normalize(hostReplacementPaths[from]));
            host.aliases.set(normalizedFrom, normalizedWith);
        }
        const compilerHost = new compiler_host_1.WebpackCompilerHost(_compilerOptions, _basePath, host, true);
        // We don't set a async resource loader on the compiler host because we only support
        // html templates, which are the only ones that can throw errors, and those can be loaded
        // synchronously.
        // If we need to also report errors on styles then we'll need to ask the main thread
        // for these resources.
        this._compilerHost = compiler_cli_1.createCompilerHost({
            options: this._compilerOptions,
            tsHost: compilerHost,
        });
github johandb / svg-drawing-tool / node_modules / @ngtools / webpack / src / compiler_host.js View on Github external
constructor(_options, basePath, host, cacheSourceFiles, directTemplateLoading = false) {
        this._options = _options;
        this.cacheSourceFiles = cacheSourceFiles;
        this.directTemplateLoading = directTemplateLoading;
        this._changedFiles = new Set();
        this._sourceFileCache = new Map();
        this._virtualFileExtensions = [
            '.js', '.js.map',
            '.ngfactory.js', '.ngfactory.js.map',
            '.ngstyle.js', '.ngstyle.js.map',
            '.ngsummary.json',
        ];
        this._syncHost = new core_1.virtualFs.SyncDelegateHost(host);
        this._memoryHost = new core_1.virtualFs.SyncDelegateHost(new core_1.virtualFs.SimpleMemoryHost());
        this._basePath = core_1.normalize(basePath);
    }
    get virtualFiles() {
github johandb / svg-drawing-tool / node_modules / @angular / cli / models / schematic-command.js View on Github external
createWorkflow(options) {
        if (this._workflow) {
            return this._workflow;
        }
        const { force, dryRun } = options;
        const fsHost = new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), core_1.normalize(this.workspace.root));
        const workflow = new tools_1.NodeWorkflow(fsHost, {
            force,
            dryRun,
            packageManager: package_manager_1.getPackageManager(this.workspace.root),
            root: core_1.normalize(this.workspace.root),
        });
        this._engineHost.registerOptionsTransform(tools_1.validateOptionsWithSchema(workflow.registry));
        if (options.defaults) {
            workflow.registry.addPreTransform(core_1.schema.transforms.addUndefinedDefaults);
        }
        else {
            workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
        }
        workflow.registry.addSmartDefaultProvider('projectName', () => {
            if (this._workspace) {
                try {
github angular / angular-devkit-schematics-builds / src / tree / filesystem.js View on Github external
constructor(host) {
        super();
        this._initialized = false;
        this._host = new core_1.virtualFs.SyncDelegateHost(host);
        this._root = new FileSystemDirEntry(this._host, this);
    }
    get tree() {
github rxweb / rxweb / rxweb.io / node_modules / @angular-devkit / build-angular / src / angular-cli-files / utilities / service-worker / index.js View on Github external
    }), operators_1.map(content => JSON.parse(core_1.virtualFs.fileBufferToString(content))), operators_1.switchMap(configJson => {
        const GeneratorConstructor = require(swConfigPath).Generator;
github rxweb / rxweb / rxweb.io / node_modules / @angular-devkit / architect / src / architect.js View on Github external
        return this._workspace.host.read(core_1.normalize(path)).pipe(operators_1.map(buffer => core_1.virtualFs.fileBufferToString(buffer)), operators_1.map(str => core_1.parseJson(str, core_1.JsonParseMode.Loose)));
    }
github rxweb / rxweb / rxweb.io / node_modules / @ngtools / webpack / src / compiler_host.js View on Github external
constructor(_options, basePath, _host = new node_1.NodeJsSyncHost()) {
        this._options = _options;
        this._host = _host;
        this._files = Object.create(null);
        this._directories = Object.create(null);
        this._changedFiles = Object.create(null);
        this._changedDirs = Object.create(null);
        this._cache = false;
        this._syncHost = new core_1.virtualFs.SyncDelegateHost(_host);
        this._setParentNodes = true;
        this._basePath = this._normalizePath(basePath);
    }
    _normalizePath(path) {
github johandb / svg-drawing-tool / node_modules / @angular-devkit / build-angular / src / app-shell / index.js View on Github external
.then(async (html) => {
                await this.context.host
                    .write(outputIndexPath, core_1.virtualFs.stringToFileBuffer(html))
                    .toPromise();
                if (browserOptions.serviceWorker) {
                    await service_worker_1.augmentAppWithServiceWorker(this.context.host, root, projectRoot, core_1.join(root, browserOptions.outputPath), browserOptions.baseHref || '/', browserOptions.ngswConfigPath);
                }
                return { success: true };
            }));
        }));