aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/@angular/cli/models/schematic-engine-host.js
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-03-01 20:05:50 +0100
committerNevena Bojovic <nenabojov@gmail.com>2022-03-01 20:05:50 +0100
commit291803c31f829fe0d32bb3207bc11def95a7408c (patch)
treec7d43107d79291b19d8c9eceefbe91c9f9a52acf /sandbox/testAppNevena/Front/node_modules/@angular/cli/models/schematic-engine-host.js
parent1fa69862057db4db53cfda5be9c24b4228ef63f7 (diff)
Urađena test aplikacija. Povezan front i back.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/@angular/cli/models/schematic-engine-host.js')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/@angular/cli/models/schematic-engine-host.js172
1 files changed, 172 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/@angular/cli/models/schematic-engine-host.js b/sandbox/testAppNevena/Front/node_modules/@angular/cli/models/schematic-engine-host.js
new file mode 100644
index 00000000..ed950e2b
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/@angular/cli/models/schematic-engine-host.js
@@ -0,0 +1,172 @@
+"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 __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+var _a;
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.SchematicEngineHost = void 0;
+const schematics_1 = require("@angular-devkit/schematics");
+const tools_1 = require("@angular-devkit/schematics/tools");
+const fs_1 = require("fs");
+const jsonc_parser_1 = require("jsonc-parser");
+const module_1 = __importDefault(require("module"));
+const path_1 = require("path");
+const vm_1 = require("vm");
+/**
+ * Environment variable to control schematic package redirection
+ * Default: Angular schematics only
+ */
+const schematicRedirectVariable = (_a = process.env['NG_SCHEMATIC_REDIRECT']) === null || _a === void 0 ? void 0 : _a.toLowerCase();
+function shouldWrapSchematic(schematicFile) {
+ // Check environment variable if present
+ if (schematicRedirectVariable !== undefined) {
+ switch (schematicRedirectVariable) {
+ case '0':
+ case 'false':
+ case 'off':
+ case 'none':
+ return false;
+ case 'all':
+ return true;
+ }
+ }
+ const normalizedSchematicFile = schematicFile.replace(/\\/g, '/');
+ // Never wrap the internal update schematic when executed directly
+ // It communicates with the update command via `global`
+ // But we still want to redirect schematics located in `@angular/cli/node_modules`.
+ if (normalizedSchematicFile.includes('node_modules/@angular/cli/') &&
+ !normalizedSchematicFile.includes('node_modules/@angular/cli/node_modules/')) {
+ return false;
+ }
+ // Default is only first-party Angular schematic packages
+ // Angular schematics are safe to use in the wrapped VM context
+ return /\/node_modules\/@(?:angular|schematics|nguniversal)\//.test(normalizedSchematicFile);
+}
+class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
+ _resolveReferenceString(refString, parentPath) {
+ const [path, name] = refString.split('#', 2);
+ // Mimic behavior of ExportStringRef class used in default behavior
+ const fullPath = path[0] === '.' ? (0, path_1.resolve)(parentPath !== null && parentPath !== void 0 ? parentPath : process.cwd(), path) : path;
+ const schematicFile = require.resolve(fullPath, { paths: [parentPath] });
+ if (shouldWrapSchematic(schematicFile)) {
+ const schematicPath = (0, path_1.dirname)(schematicFile);
+ const moduleCache = new Map();
+ const factoryInitializer = wrap(schematicFile, schematicPath, moduleCache, name || 'default');
+ const factory = factoryInitializer();
+ if (!factory || typeof factory !== 'function') {
+ return null;
+ }
+ return { ref: factory, path: schematicPath };
+ }
+ // All other schematics use default behavior
+ return super._resolveReferenceString(refString, parentPath);
+ }
+}
+exports.SchematicEngineHost = SchematicEngineHost;
+/**
+ * Minimal shim modules for legacy deep imports of `@schematics/angular`
+ */
+const legacyModules = {
+ '@schematics/angular/utility/config': {
+ getWorkspace(host) {
+ const path = '/.angular.json';
+ const data = host.read(path);
+ if (!data) {
+ throw new schematics_1.SchematicsException(`Could not find (${path})`);
+ }
+ return (0, jsonc_parser_1.parse)(data.toString(), [], { allowTrailingComma: true });
+ },
+ },
+ '@schematics/angular/utility/project': {
+ buildDefaultPath(project) {
+ const root = project.sourceRoot ? `/${project.sourceRoot}/` : `/${project.root}/src/`;
+ return `${root}${project.projectType === 'application' ? 'app' : 'lib'}`;
+ },
+ },
+};
+/**
+ * Wrap a JavaScript file in a VM context to allow specific Angular dependencies to be redirected.
+ * This VM setup is ONLY intended to redirect dependencies.
+ *
+ * @param schematicFile A JavaScript schematic file path that should be wrapped.
+ * @param schematicDirectory A directory that will be used as the location of the JavaScript file.
+ * @param moduleCache A map to use for caching repeat module usage and proper `instanceof` support.
+ * @param exportName An optional name of a specific export to return. Otherwise, return all exports.
+ */
+function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
+ const hostRequire = module_1.default.createRequire(__filename);
+ const schematicRequire = module_1.default.createRequire(schematicFile);
+ const customRequire = function (id) {
+ if (legacyModules[id]) {
+ // Provide compatibility modules for older versions of @angular/cdk
+ return legacyModules[id];
+ }
+ else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
+ // Files should not redirect `@angular/core` and instead use the direct
+ // dependency if available. This allows old major version migrations to continue to function
+ // even though the latest major version may have breaking changes in `@angular/core`.
+ if (id.startsWith('@angular-devkit/core')) {
+ try {
+ return schematicRequire(id);
+ }
+ catch (e) {
+ if (e.code !== 'MODULE_NOT_FOUND') {
+ throw e;
+ }
+ }
+ }
+ // Resolve from inside the `@angular/cli` project
+ return hostRequire(id);
+ }
+ else if (id.startsWith('.') || id.startsWith('@angular/cdk')) {
+ // Wrap relative files inside the schematic collection
+ // Also wrap `@angular/cdk`, it contains helper utilities that import core schematic packages
+ // Resolve from the original file
+ const modulePath = schematicRequire.resolve(id);
+ // Use cached module if available
+ const cachedModule = moduleCache.get(modulePath);
+ if (cachedModule) {
+ return cachedModule;
+ }
+ // Do not wrap vendored third-party packages or JSON files
+ if (!/[/\\]node_modules[/\\]@schematics[/\\]angular[/\\]third_party[/\\]/.test(modulePath) &&
+ !modulePath.endsWith('.json')) {
+ // Wrap module and save in cache
+ const wrappedModule = wrap(modulePath, (0, path_1.dirname)(modulePath), moduleCache)();
+ moduleCache.set(modulePath, wrappedModule);
+ return wrappedModule;
+ }
+ }
+ // All others are required directly from the original file
+ return schematicRequire(id);
+ };
+ // Setup a wrapper function to capture the module's exports
+ const schematicCode = (0, fs_1.readFileSync)(schematicFile, 'utf8');
+ // `module` is required due to @angular/localize ng-add being in UMD format
+ const headerCode = '(function() {\nvar exports = {};\nvar module = { exports };\n';
+ const footerCode = exportName ? `\nreturn exports['${exportName}'];});` : '\nreturn exports;});';
+ const script = new vm_1.Script(headerCode + schematicCode + footerCode, {
+ filename: schematicFile,
+ lineOffset: 3,
+ });
+ const context = {
+ __dirname: schematicDirectory,
+ __filename: schematicFile,
+ Buffer,
+ console,
+ process,
+ get global() {
+ return this;
+ },
+ require: customRequire,
+ };
+ const exportsFactory = script.runInNewContext(context);
+ return exportsFactory;
+}