@energycap/components 0.39.8-ECAP-23648-dropdown-arrow-color-fix.20240223-1554 → 0.39.8-schematics.20240307-1409

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.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@energycap/components",
3
- "version": "0.39.8-ECAP-23648-dropdown-arrow-color-fix.20240223-1554",
3
+ "version": "0.39.8-schematics.20240307-1409",
4
+ "schematics": "./schematics/collection.json",
4
5
  "dependencies": {
5
6
  "tslib": "^2.0.0"
6
7
  },
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "rxjs-7-upgrade": {
5
+ "description": "Upgrade your project to RxJS 7",
6
+ "factory": "./ng-generate/rxjs-7-upgrade/index#rxjs7Upgrade"
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,2 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ export declare function rxjs7Upgrade(): Rule;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.rxjs7Upgrade = void 0;
13
+ const core_1 = require("@angular-devkit/core");
14
+ const workspace_1 = require("@schematics/angular/utility/workspace");
15
+ const ts = require("typescript");
16
+ const path_1 = require("path");
17
+ // import { insertImport, findNodes } from '@schematics/angular/utility/ast-utils';
18
+ function rxjs7Upgrade() {
19
+ return (tree) => __awaiter(this, void 0, void 0, function* () {
20
+ const workspaceHost = createWorkspaceHost(tree);
21
+ const { workspace } = yield core_1.workspaces.readWorkspace('/', workspaceHost);
22
+ // Get all tsconfig paths from the workspace, including test tsconfigs
23
+ const tsConfigPaths = getTsConfigPaths(workspace, tree);
24
+ // The base path in the file system for the workspace. This is needed for the typescript compiler to resolve files correctly.
25
+ const basePath = process.cwd().replace(/\\/g, '/');
26
+ tsConfigPaths.forEach(tsConfigPath => {
27
+ const program = createTsProgram(tree, tsConfigPath, basePath);
28
+ const printer = ts.createPrinter();
29
+ const checker = program.getTypeChecker();
30
+ // const migratedFiles = new Map<string, string>();
31
+ const transformer = getTransformer(checker);
32
+ for (const sourceFile of program.getSourceFiles()) {
33
+ // Skip declaration files and external library files
34
+ if (sourceFile.isDeclarationFile || program.isSourceFileFromExternalLibrary(sourceFile)) {
35
+ continue;
36
+ }
37
+ const result = ts.transform(sourceFile, [transformer]);
38
+ const transformedSourceFile = result.transformed[0];
39
+ const transformedContent = printer.printFile(transformedSourceFile);
40
+ console.log(transformedContent === sourceFile.getFullText() ? 'No changes' : 'Changes detected');
41
+ }
42
+ });
43
+ });
44
+ }
45
+ exports.rxjs7Upgrade = rxjs7Upgrade;
46
+ function createWorkspaceHost(tree) {
47
+ return {
48
+ readFile(path) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const data = tree.read(path);
51
+ if (!data) {
52
+ throw new Error(`File not found: ${path}`);
53
+ }
54
+ return core_1.virtualFs.fileBufferToString(data);
55
+ });
56
+ },
57
+ writeFile(path, data) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ return tree.overwrite(path, data);
60
+ });
61
+ },
62
+ isDirectory(path) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ return !tree.exists(path) && tree.getDir(path).subfiles.length > 0;
65
+ });
66
+ },
67
+ isFile(path) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return tree.exists(path);
70
+ });
71
+ }
72
+ };
73
+ }
74
+ function getTsConfigPaths(workspace, tree) {
75
+ const buildPaths = new Set();
76
+ const testPaths = new Set();
77
+ for (const [name, target] of (0, workspace_1.allWorkspaceTargets)(workspace)) {
78
+ if (name !== 'build' && name !== 'test') {
79
+ continue;
80
+ }
81
+ for (const [, options] of (0, workspace_1.allTargetOptions)(target)) {
82
+ if (options.tsConfig && typeof options.tsConfig === 'string' && tree.exists(options.tsConfig)) {
83
+ const normalizedPath = (0, core_1.normalize)(options.tsConfig);
84
+ name === 'build' ? buildPaths.add(normalizedPath) : testPaths.add(normalizedPath);
85
+ }
86
+ }
87
+ }
88
+ return [...buildPaths];
89
+ }
90
+ function createTsProgram(tree, tsConfigPath, basePath) {
91
+ tsConfigPath = (0, path_1.resolve)(basePath, tsConfigPath);
92
+ const parsed = parseTsConfig(tsConfigPath, (0, path_1.dirname)(tsConfigPath));
93
+ const options = Object.assign(Object.assign({}, parsed.options), { skipLibCheck: true, skipDefaultLibCheck: true });
94
+ const host = createTsCompilerHost(tree, options, basePath);
95
+ return ts.createProgram(parsed.fileNames, options, host);
96
+ }
97
+ function parseTsConfig(tsConfigPath, basePath) {
98
+ const { config } = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
99
+ const parseHost = {
100
+ useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
101
+ fileExists: ts.sys.fileExists,
102
+ readFile: ts.sys.readFile,
103
+ readDirectory: ts.sys.readDirectory
104
+ };
105
+ return ts.parseJsonConfigFileContent(config, parseHost, basePath, {});
106
+ }
107
+ function createTsCompilerHost(tree, options, basePath) {
108
+ const host = ts.createCompilerHost(options);
109
+ // Read files from the virtual tree to prevent conflicting changes between project migrations
110
+ host.readFile = (fileName) => {
111
+ var _a;
112
+ const relativePath = (0, path_1.relative)(basePath, fileName);
113
+ const result = (_a = tree.read(relativePath)) === null || _a === void 0 ? void 0 : _a.toString();
114
+ // Remove BOM header to prevent TSC parsing errors
115
+ return result === null || result === void 0 ? void 0 : result.replace(/^\uFEFF/, '');
116
+ };
117
+ return host;
118
+ }
119
+ function getTransformer(checker) {
120
+ return (context) => {
121
+ const visit = (node) => {
122
+ // Check if this is a call expression where the expression is a property access expression with the name 'toPromise'
123
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === 'toPromise') {
124
+ // Get the type of the object on which 'toPromise' is being called
125
+ const symbol = checker.getTypeAtLocation(node.expression.expression).symbol;
126
+ if (symbol && ['Observable', 'Subject', 'BehaviorSubject', 'ReplaySubject', 'AsyncSubject'].includes(symbol.name)) {
127
+ // Replace the node with a call expression where the expression is an identifier with the name 'lastValueFrom'
128
+ return ts.factory.createCallExpression(ts.factory.createIdentifier('lastValueFrom'), undefined, [node.expression.expression]);
129
+ }
130
+ }
131
+ return ts.visitEachChild(node, visit, context);
132
+ };
133
+ return (sourceFile) => ts.visitNode(sourceFile, visit);
134
+ };
135
+ }
136
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/components/schematics/ng-generate/rxjs-7-upgrade/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+CAAwE;AACxE,qEAA8F;AAC9F,iCAAiC;AACjC,+BAAkD;AAClD,mFAAmF;AAEnF,SAAgB,YAAY;IAC1B,OAAO,CAAO,IAAU,EAAE,EAAE;QAC1B,MAAM,aAAa,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,iBAAU,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAEzE,sEAAsE;QACtE,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACxD,6HAA6H;QAC7H,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEnD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