@ngxs/storage-plugin 18.0.0 → 18.1.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.
- package/esm2022/src/keys-manager.mjs +3 -3
- package/esm2022/src/storage.module.mjs +4 -4
- package/esm2022/src/storage.plugin.mjs +3 -3
- package/fesm2022/ngxs-storage-plugin.mjs +10 -10
- package/package.json +2 -2
- package/schematics/collection.json +12 -0
- package/schematics/src/ng-generate/__snapshots__/keys-migration.spec.ts.snap +125 -0
- package/schematics/src/ng-generate/index.d.ts +2 -0
- package/schematics/src/ng-generate/index.js +99 -0
- package/schematics/src/ng-generate/index.js.map +1 -0
- package/schematics/src/ng-generate/schema.json +7 -0
- package/schematics/src/utils/versions.json +3 -0
- package/schematics/src/utils/visit-files.d.ts +2 -0
- package/schematics/src/utils/visit-files.js +24 -0
- package/schematics/src/utils/visit-files.js.map +1 -0
|
@@ -33,10 +33,10 @@ export class ɵNgxsStoragePluginKeysManager {
|
|
|
33
33
|
this._keysWithEngines.push({ key, engine });
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
37
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
36
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: ɵNgxsStoragePluginKeysManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
37
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: ɵNgxsStoragePluginKeysManager, providedIn: 'root' }); }
|
|
38
38
|
}
|
|
39
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
39
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: ɵNgxsStoragePluginKeysManager, decorators: [{
|
|
40
40
|
type: Injectable,
|
|
41
41
|
args: [{ providedIn: 'root' }]
|
|
42
42
|
}], ctorParameters: () => [] });
|
|
@@ -32,11 +32,11 @@ export class NgxsStoragePluginModule {
|
|
|
32
32
|
]
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
36
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
37
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
35
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
36
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule }); }
|
|
37
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule }); }
|
|
38
38
|
}
|
|
39
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
39
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule, decorators: [{
|
|
40
40
|
type: NgModule
|
|
41
41
|
}] });
|
|
42
42
|
export function withNgxsStoragePlugin(options) {
|
|
@@ -130,10 +130,10 @@ export class NgxsStoragePlugin {
|
|
|
130
130
|
return accumulator;
|
|
131
131
|
}, {});
|
|
132
132
|
}
|
|
133
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
134
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
133
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePlugin, deps: [{ token: i1.ɵNgxsStoragePluginKeysManager }, { token: ɵNGXS_STORAGE_PLUGIN_OPTIONS }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
134
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePlugin }); }
|
|
135
135
|
}
|
|
136
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
136
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePlugin, decorators: [{
|
|
137
137
|
type: Injectable
|
|
138
138
|
}], ctorParameters: () => [{ type: i1.ɵNgxsStoragePluginKeysManager }, { type: undefined, decorators: [{
|
|
139
139
|
type: Inject,
|
|
@@ -68,10 +68,10 @@ class ɵNgxsStoragePluginKeysManager {
|
|
|
68
68
|
this._keysWithEngines.push({ key, engine });
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
72
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
71
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: ɵNgxsStoragePluginKeysManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
72
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: ɵNgxsStoragePluginKeysManager, providedIn: 'root' }); }
|
|
73
73
|
}
|
|
74
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
74
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: ɵNgxsStoragePluginKeysManager, decorators: [{
|
|
75
75
|
type: Injectable,
|
|
76
76
|
args: [{ providedIn: 'root' }]
|
|
77
77
|
}], ctorParameters: () => [] });
|
|
@@ -199,10 +199,10 @@ class NgxsStoragePlugin {
|
|
|
199
199
|
return accumulator;
|
|
200
200
|
}, {});
|
|
201
201
|
}
|
|
202
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
203
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
202
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePlugin, deps: [{ token: ɵNgxsStoragePluginKeysManager }, { token: _NGXS_STORAGE_PLUGIN_OPTIONS }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
203
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePlugin }); }
|
|
204
204
|
}
|
|
205
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
205
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePlugin, decorators: [{
|
|
206
206
|
type: Injectable
|
|
207
207
|
}], ctorParameters: () => [{ type: ɵNgxsStoragePluginKeysManager }, { type: undefined, decorators: [{
|
|
208
208
|
type: Inject,
|
|
@@ -240,11 +240,11 @@ class NgxsStoragePluginModule {
|
|
|
240
240
|
]
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
244
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
245
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
243
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
244
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule }); }
|
|
245
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule }); }
|
|
246
246
|
}
|
|
247
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
247
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.6", ngImport: i0, type: NgxsStoragePluginModule, decorators: [{
|
|
248
248
|
type: NgModule
|
|
249
249
|
}] });
|
|
250
250
|
function withNgxsStoragePlugin(options) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngxs/storage-plugin",
|
|
3
3
|
"description": "extendable storage plugin for @ngxs/store",
|
|
4
|
-
"version": "18.
|
|
4
|
+
"version": "18.1.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@ngxs/store": "^18.
|
|
7
|
+
"@ngxs/store": "^18.1.0 || ^18.1.0-dev",
|
|
8
8
|
"@angular/core": ">=16.0.0 <19.0.0",
|
|
9
9
|
"rxjs": ">=6.5.5",
|
|
10
10
|
"ts-morph": "21.0.1"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["@schematics/angular"],
|
|
3
|
+
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
4
|
+
"schematics": {
|
|
5
|
+
"keys-migration": {
|
|
6
|
+
"factory": "./src/ng-generate/index#migrateKeys",
|
|
7
|
+
"description": "Migrates from key to keys",
|
|
8
|
+
"aliases": ["ngxs-keys-migration"],
|
|
9
|
+
"schema": "./src/ng-generate/schema.json"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Storage Plugin Migration migrate empty forRoot 1`] = `
|
|
4
|
+
"
|
|
5
|
+
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
|
|
6
|
+
import { NgModule } from '@angular/core';
|
|
7
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
8
|
+
|
|
9
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
10
|
+
import { AppComponent } from './app.component';
|
|
11
|
+
|
|
12
|
+
@NgModule({
|
|
13
|
+
declarations: [
|
|
14
|
+
AppComponent
|
|
15
|
+
],
|
|
16
|
+
imports: [
|
|
17
|
+
BrowserModule,
|
|
18
|
+
AppRoutingModule,
|
|
19
|
+
NgxsStoragePluginModule.forRoot({ keys: '*' })
|
|
20
|
+
],
|
|
21
|
+
bootstrap: [AppComponent]
|
|
22
|
+
})
|
|
23
|
+
export class AppModule { }
|
|
24
|
+
"
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`Storage Plugin Migration migrate forRoot that has the "key" property with a value as a string literal 1`] = `
|
|
28
|
+
"
|
|
29
|
+
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
|
|
30
|
+
import { NgModule } from '@angular/core';
|
|
31
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
32
|
+
|
|
33
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
34
|
+
import { AppComponent } from './app.component';
|
|
35
|
+
|
|
36
|
+
@NgModule({
|
|
37
|
+
declarations: [
|
|
38
|
+
AppComponent
|
|
39
|
+
],
|
|
40
|
+
imports: [
|
|
41
|
+
BrowserModule,
|
|
42
|
+
AppRoutingModule,
|
|
43
|
+
NgxsStoragePluginModule.forRoot({proa: 'valuea', prob: 'valueb', keys: ['keep this value']})
|
|
44
|
+
],
|
|
45
|
+
bootstrap: [AppComponent]
|
|
46
|
+
})
|
|
47
|
+
export class AppModule { }
|
|
48
|
+
"
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
exports[`Storage Plugin Migration migrate forRoot that has the "key" property with values as an array literal 1`] = `
|
|
52
|
+
"
|
|
53
|
+
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
|
|
54
|
+
import { NgModule } from '@angular/core';
|
|
55
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
56
|
+
|
|
57
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
58
|
+
import { AppComponent } from './app.component';
|
|
59
|
+
|
|
60
|
+
@NgModule({
|
|
61
|
+
declarations: [
|
|
62
|
+
AppComponent
|
|
63
|
+
],
|
|
64
|
+
imports: [
|
|
65
|
+
BrowserModule,
|
|
66
|
+
AppRoutingModule,
|
|
67
|
+
NgxsStoragePluginModule.forRoot({proa: 'valuea', prob: 'valueb', keys: ['keyValue', NovelsState, { key: 'novels', engine: MyEngineX } ]})
|
|
68
|
+
],
|
|
69
|
+
bootstrap: [AppComponent]
|
|
70
|
+
})
|
|
71
|
+
export class AppModule { }
|
|
72
|
+
"
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
exports[`Storage Plugin Migration migrate forRoot that is missing the "key" property 1`] = `
|
|
76
|
+
"
|
|
77
|
+
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
|
|
78
|
+
import { NgModule } from '@angular/core';
|
|
79
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
80
|
+
|
|
81
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
82
|
+
import { AppComponent } from './app.component';
|
|
83
|
+
|
|
84
|
+
@NgModule({
|
|
85
|
+
declarations: [
|
|
86
|
+
AppComponent
|
|
87
|
+
],
|
|
88
|
+
imports: [
|
|
89
|
+
BrowserModule,
|
|
90
|
+
AppRoutingModule,
|
|
91
|
+
NgxsStoragePluginModule.forRoot({proa: 'valuea', prob: 'valueb',
|
|
92
|
+
keys: '*'
|
|
93
|
+
})
|
|
94
|
+
],
|
|
95
|
+
bootstrap: [AppComponent]
|
|
96
|
+
})
|
|
97
|
+
export class AppModule { }
|
|
98
|
+
"
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
exports[`Storage Plugin Migration migrate from a constant array 1`] = `
|
|
102
|
+
"
|
|
103
|
+
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
|
|
104
|
+
import { NgModule } from '@angular/core';
|
|
105
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
106
|
+
|
|
107
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
108
|
+
import { AppComponent } from './app.component';
|
|
109
|
+
|
|
110
|
+
const imports = [
|
|
111
|
+
BrowserModule,
|
|
112
|
+
AppRoutingModule,
|
|
113
|
+
NgxsStoragePluginModule.forRoot({proa: 'valuea', prob: 'valueb', keys: ['keep this value']})
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
@NgModule({
|
|
117
|
+
declarations: [
|
|
118
|
+
AppComponent
|
|
119
|
+
],
|
|
120
|
+
imports,
|
|
121
|
+
bootstrap: [AppComponent]
|
|
122
|
+
})
|
|
123
|
+
export class AppModule { }
|
|
124
|
+
"
|
|
125
|
+
`;
|
|
@@ -0,0 +1,99 @@
|
|
|
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.migrateKeys = void 0;
|
|
13
|
+
const node_process_1 = require("node:process");
|
|
14
|
+
const ts = require("ts-morph");
|
|
15
|
+
const visit_files_1 = require("../utils/visit-files");
|
|
16
|
+
function migrateEmptyForRoot(callExpression) {
|
|
17
|
+
callExpression.addArgument(`{ keys: '*' }`);
|
|
18
|
+
}
|
|
19
|
+
function migrateForRootWithArgs(arg) {
|
|
20
|
+
const objectLiteral = arg;
|
|
21
|
+
const hasPropertyName = (name) => objectLiteral.getProperties().some(prop => {
|
|
22
|
+
return ts.Node.isPropertyAssignment(prop) && prop.getName() === name;
|
|
23
|
+
});
|
|
24
|
+
const isAlreadyMigrated = hasPropertyName('keys');
|
|
25
|
+
// If the "keys" property is already there, we should not try migrating
|
|
26
|
+
if (isAlreadyMigrated) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const hasKeyProperty = hasPropertyName('key');
|
|
30
|
+
// Add the "keys" property if it's not there
|
|
31
|
+
if (!hasKeyProperty) {
|
|
32
|
+
objectLiteral.addPropertyAssignment({ name: 'keys', initializer: `'*'` });
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Rename the "key" property to "keys"
|
|
36
|
+
const keyProperty = objectLiteral.getProperty('key');
|
|
37
|
+
const propertyName = keyProperty === null || keyProperty === void 0 ? void 0 : keyProperty.getChildAtIndex(0);
|
|
38
|
+
const propertyValue = keyProperty === null || keyProperty === void 0 ? void 0 : keyProperty.getChildAtIndex(2);
|
|
39
|
+
propertyName === null || propertyName === void 0 ? void 0 : propertyName.replaceWithText('keys');
|
|
40
|
+
// if the property value is a string literal, then we should wrap it in an array
|
|
41
|
+
// We are checking the isStringLiteral to avoid wrapping a value that is already an array
|
|
42
|
+
if (ts.Node.isStringLiteral(propertyValue)) {
|
|
43
|
+
propertyValue === null || propertyValue === void 0 ? void 0 : propertyValue.replaceWithText(`[${propertyValue === null || propertyValue === void 0 ? void 0 : propertyValue.getText()}]`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function isStoragePluginProvided(callExpression) {
|
|
48
|
+
return (callExpression && callExpression.getText().includes('NgxsStoragePluginModule.forRoot'));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* We do not use the ts.Node.isCallExpression(node) because the underlying implementation
|
|
52
|
+
* uses -> node.getKind() === typescript.SyntaxKind.CallExpression
|
|
53
|
+
* which is an enum that can return different numbers depending on minor typescript package versions
|
|
54
|
+
*/
|
|
55
|
+
function isCallExpression(node) {
|
|
56
|
+
return node.getKindName() === 'CallExpression';
|
|
57
|
+
}
|
|
58
|
+
function migrateKeys() {
|
|
59
|
+
return (tree, _context) => {
|
|
60
|
+
const tsProject = new ts.Project({ useInMemoryFileSystem: true });
|
|
61
|
+
const packageJson = tree.readJson('package.json');
|
|
62
|
+
const storePackage = packageJson['dependencies']['@ngxs/store'];
|
|
63
|
+
if (!storePackage) {
|
|
64
|
+
_context.logger.error(`No @ngxs/store found`);
|
|
65
|
+
return (0, node_process_1.exit)(1);
|
|
66
|
+
}
|
|
67
|
+
(0, visit_files_1.visitTsFiles)(tree, tree.root, (path) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const fileContent = tree.readText(path);
|
|
69
|
+
const sourceFile = tsProject.createSourceFile(path, fileContent);
|
|
70
|
+
const hasStoragePluginImported = sourceFile.getImportDeclaration(importDecl => importDecl.getModuleSpecifierValue() === '@ngxs/storage-plugin');
|
|
71
|
+
// do not try migrating if the storage plugin is not imported
|
|
72
|
+
if (hasStoragePluginImported) {
|
|
73
|
+
sourceFile.forEachDescendant(node => {
|
|
74
|
+
if (isCallExpression(node) &&
|
|
75
|
+
ts.Node.isPropertyAccessExpression(node.getExpression())) {
|
|
76
|
+
const callExpression = node;
|
|
77
|
+
// If the storage plugin is not provided, we should not try migrating
|
|
78
|
+
if (!isStoragePluginProvided(callExpression)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const args = callExpression.getArguments();
|
|
82
|
+
// If there are no arguments in the forRoot(), then add the `keys` property
|
|
83
|
+
if (!args.length) {
|
|
84
|
+
_context.logger.info(`Migrating empty forRoot in ${path}`);
|
|
85
|
+
migrateEmptyForRoot(callExpression);
|
|
86
|
+
}
|
|
87
|
+
else if (ts.Node.isObjectLiteralExpression(args[0])) {
|
|
88
|
+
_context.logger.info(`Migrating forRoot with args in ${path}`);
|
|
89
|
+
migrateForRootWithArgs(args[0]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
tree.overwrite(path, sourceFile.getFullText());
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
exports.migrateKeys = migrateKeys;
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/storage-plugin/schematics/src/ng-generate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoC;AACpC,+BAA+B;AAG/B,sDAAoD;AAEpD,SAAS,mBAAmB,CAAC,cAAuD;IAClF,cAAc,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAwB;IACtD,MAAM,aA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wBACtB,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EACxD,CAAC;wBACD,MAAM,cAAc,GAAG,IAAyB,CAAC;wBAEjD,qEAAqE;wBACrE,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,EAAE,CAAC;4BAC7C,OAAO;wBACT,CAAC;wBAED,MAAM,IAAI,GAAG,cAAc,CAAC,YAAY,EAAE,CAAC;wBAC3C,2EAA2E;wBAC3E,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;4BACjB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;4BAC3D,mBAAmB,CAAC,cAAc,CAAC,CAAC;wBACtC,CAAC;6BAAM,IAAI,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;4BACtD,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;4BAC/D,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;wBAClC,CAAC;oBACH,CAAC;gBACH,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;YACjD,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAhDD,kCAgDC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.visitTsFiles = void 0;
|
|
4
|
+
function visitTsFiles(tree, dirPath = tree.root, visitor) {
|
|
5
|
+
function visit(directory) {
|
|
6
|
+
for (const path of directory.subfiles) {
|
|
7
|
+
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
|
|
8
|
+
const entry = directory.file(path);
|
|
9
|
+
if (entry) {
|
|
10
|
+
visitor(entry.path);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (const path of directory.subdirs) {
|
|
15
|
+
if (path === 'node_modules') {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
visit(directory.dir(path));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
visit(dirPath);
|
|
22
|
+
}
|
|
23
|
+
exports.visitTsFiles = visitTsFiles;
|
|
24
|
+
//# sourceMappingURL=visit-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visit-files.js","sourceRoot":"","sources":["../../../../../packages/storage-plugin/schematics/src/utils/visit-files.ts"],"names":[],"mappings":";;;AAEA,SAAgB,YAAY,CAC1B,IAAU,EACV,OAAO,GAAG,IAAI,CAAC,IAAI,EACnB,OAA+B;IAE/B,SAAS,KAAK,CAAC,SAAmB;QAChC,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnC,IAAI,KAAK,EAAE,CAAC;oBACV,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACrC,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;gBAC5B,SAAS;YACX,CAAC;YAED,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,CAAC;AACjB,CAAC;AAzBD,oCAyBC"}
|