@rxap/ngx-memory 22.0.0-dev.0 → 22.0.0-dev.2
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/CHANGELOG.md +22 -0
- package/README.md +5 -3
- package/compodoc/architecture.html +222 -0
- package/compodoc/changelog.html +66 -5
- package/compodoc/classes/MockStorage.html +114 -37
- package/compodoc/dependencies.html +80 -13
- package/compodoc/index.html +50 -8
- package/compodoc/injectables/EphemeralStorageService.html +107 -24
- package/compodoc/injectables/LocalStorageService.html +107 -24
- package/compodoc/injectables/SessionStorageService.html +107 -24
- package/compodoc/injectables/StorageService.html +96 -18
- package/compodoc/js/architecture-graph.js +288 -0
- package/compodoc/js/libs/bootstrap-native.js +4 -2
- package/compodoc/js/libs/jszip.min.js +13 -0
- package/compodoc/js/libs/svg-pan-zoom.min.js +3 -3
- package/compodoc/js/libs/tablesort.min.js +3 -3
- package/compodoc/js/libs/tablesort.number.min.js +3 -3
- package/compodoc/js/libs/vis-network.min.js +78 -0
- package/compodoc/js/menu-wc.js +25 -12
- package/compodoc/js/menu.js +10 -11
- package/compodoc/js/routes/routes_index.js +1 -0
- package/compodoc/js/routes.js +142 -34
- package/compodoc/js/search/search-lunr.js +6 -8
- package/compodoc/js/search/search.js +118 -66
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/js/tabs.js +98 -15
- package/compodoc/js/tree.js +44 -7
- package/compodoc/license.html +48 -6
- package/compodoc/llms.txt +108 -0
- package/compodoc/miscellaneous/functions.html +156 -23
- package/compodoc/miscellaneous/typealiases.html +46 -4
- package/compodoc/miscellaneous/variables.html +58 -5
- package/compodoc/modules.html +44 -3
- package/compodoc/overview.html +54 -3
- package/compodoc/properties.html +45 -4
- package/compodoc/routes.html +227 -0
- package/compodoc/styles/compodoc.css +365 -44
- package/compodoc/styles/dark.css +16 -0
- package/compodoc/template-playground/default-templates.json +192 -0
- package/compodoc/template-playground/hbs-render.service.ts +217 -0
- package/compodoc/template-playground/main.ts +9 -0
- package/compodoc/template-playground/template-editor.service.ts +173 -0
- package/compodoc/template-playground/template-playground.component.ts +614 -0
- package/compodoc/template-playground/template-playground.module.ts +29 -0
- package/compodoc/template-playground/zip-export.service.ts +86 -0
- package/compodoc/template-playground-app/app.js +1389 -0
- package/compodoc/template-playground-app/index.html +462 -0
- package/compodoc/todo.html +45 -60
- package/docs/documentation.json +512 -357
- package/docs/html/assets/highlight.css +1 -1
- package/docs/html/assets/icons.js +1 -1
- package/docs/html/assets/icons.svg +1 -1
- package/docs/html/assets/main.js +5 -5
- package/docs/html/assets/search.js +1 -1
- package/docs/html/assets/style.css +265 -228
- package/docs/html/classes/EphemeralStorageService.html +151 -9
- package/docs/html/classes/LocalStorageService.html +151 -9
- package/docs/html/classes/MockStorage.html +185 -15
- package/docs/html/classes/SessionStorageService.html +151 -9
- package/docs/html/classes/StorageService.html +151 -9
- package/docs/html/functions/LocalStorage.html +52 -5
- package/docs/html/functions/SessionStorage.html +52 -5
- package/docs/html/functions/StorageGet.html +43 -1
- package/docs/html/functions/StorageHas.html +43 -1
- package/docs/html/functions/StorageKey.html +43 -1
- package/docs/html/functions/StorageRemove.html +43 -1
- package/docs/html/functions/StorageSet.html +46 -1
- package/docs/html/functions/WebStorage.html +45 -1
- package/docs/html/functions/getExpired.html +43 -1
- package/docs/html/functions/stringify.html +42 -1
- package/docs/html/hierarchy.html +35 -1
- package/docs/html/index.html +44 -7
- package/docs/html/modules.html +48 -1
- package/docs/html/types/ExpiredUnit.html +35 -2
- package/docs/html/variables/isBrowser.html +35 -2
- package/docs/markdown/README.md +6 -4
- package/docs/markdown/classes/EphemeralStorageService.md +17 -17
- package/docs/markdown/classes/LocalStorageService.md +17 -17
- package/docs/markdown/classes/MockStorage.md +16 -16
- package/docs/markdown/classes/SessionStorageService.md +17 -17
- package/docs/markdown/classes/StorageService.md +18 -18
- package/docs/markdown/functions/LocalStorage.md +4 -18
- package/docs/markdown/functions/SessionStorage.md +4 -18
- package/docs/markdown/functions/StorageGet.md +3 -3
- package/docs/markdown/functions/StorageHas.md +3 -3
- package/docs/markdown/functions/StorageKey.md +5 -5
- package/docs/markdown/functions/StorageRemove.md +3 -3
- package/docs/markdown/functions/StorageSet.md +6 -6
- package/docs/markdown/functions/WebStorage.md +5 -19
- package/docs/markdown/functions/getExpired.md +2 -2
- package/docs/markdown/functions/stringify.md +2 -2
- package/docs/markdown/globals.md +2 -2
- package/docs/markdown/type-aliases/ExpiredUnit.md +3 -3
- package/docs/markdown/variables/isBrowser.md +2 -2
- package/docs/wiki/Class.EphemeralStorageService.md +16 -16
- package/docs/wiki/Class.LocalStorageService.md +16 -16
- package/docs/wiki/Class.MockStorage.md +15 -15
- package/docs/wiki/Class.SessionStorageService.md +16 -16
- package/docs/wiki/Class.StorageService.md +17 -17
- package/docs/wiki/Function.LocalStorage.md +3 -17
- package/docs/wiki/Function.SessionStorage.md +3 -17
- package/docs/wiki/Function.StorageGet.md +2 -2
- package/docs/wiki/Function.StorageHas.md +2 -2
- package/docs/wiki/Function.StorageKey.md +4 -4
- package/docs/wiki/Function.StorageRemove.md +2 -2
- package/docs/wiki/Function.StorageSet.md +5 -5
- package/docs/wiki/Function.WebStorage.md +4 -18
- package/docs/wiki/Function.getExpired.md +1 -1
- package/docs/wiki/Function.stringify.md +1 -1
- package/docs/wiki/Home.md +5 -3
- package/docs/wiki/TypeAlias.ExpiredUnit.md +2 -2
- package/docs/wiki/Variable.isBrowser.md +1 -1
- package/docs/wiki/globals.md +1 -1
- package/generators.json +16 -0
- package/package.json +6 -8
- package/src/generators/init/generator.js +120 -0
- package/src/generators/init/index.js +6 -0
- package/src/generators/init/schema.json +8 -0
- package/src/generators/package.json +3 -0
- package/compodoc/js/libs/vis.min.js +0 -47
- package/compodoc/js/menu-wc_es5.js +0 -40
- package/theme.css +0 -1
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
> **StorageHas**(`storage`, `key`): `boolean`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:37](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:37](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L37)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
11
|
### storage
|
|
12
12
|
|
|
13
|
-
`
|
|
13
|
+
`Storage` \| `null`
|
|
14
14
|
|
|
15
15
|
### key
|
|
16
16
|
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
# Function: StorageKey()
|
|
4
4
|
|
|
5
|
-
> **StorageKey**(`storage`, `index`): `
|
|
5
|
+
> **StorageKey**(`storage`, `index`): `string` \| `null`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:65](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:65](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L65)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
11
|
### storage
|
|
12
12
|
|
|
13
|
-
`
|
|
13
|
+
`Storage` \| `null`
|
|
14
14
|
|
|
15
15
|
### index
|
|
16
16
|
|
|
@@ -18,4 +18,4 @@ Defined in: [storage-utility.ts:65](https://gitlab.com/rxap/packages/-/blob/c814
|
|
|
18
18
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
21
|
-
`
|
|
21
|
+
`string` \| `null`
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
> **StorageRemove**(`storage`, `key`): `void`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:58](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:58](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L58)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
11
|
### storage
|
|
12
12
|
|
|
13
|
-
`
|
|
13
|
+
`Storage` \| `null`
|
|
14
14
|
|
|
15
15
|
### key
|
|
16
16
|
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
# Function: StorageSet()
|
|
4
4
|
|
|
5
|
-
> **StorageSet**(`storage`, `key`, `value`, `expiredAt
|
|
5
|
+
> **StorageSet**(`storage`, `key`, `value`, `expiredAt?`, `expiredUnit?`): `void`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:44](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:44](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L44)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
11
|
### storage
|
|
12
12
|
|
|
13
|
-
`
|
|
13
|
+
`Storage` \| `null`
|
|
14
14
|
|
|
15
15
|
### key
|
|
16
16
|
|
|
@@ -20,11 +20,11 @@ Defined in: [storage-utility.ts:44](https://gitlab.com/rxap/packages/-/blob/c814
|
|
|
20
20
|
|
|
21
21
|
`any`
|
|
22
22
|
|
|
23
|
-
### expiredAt
|
|
23
|
+
### expiredAt?
|
|
24
24
|
|
|
25
25
|
`number` = `0`
|
|
26
26
|
|
|
27
|
-
### expiredUnit
|
|
27
|
+
### expiredUnit?
|
|
28
28
|
|
|
29
29
|
[`ExpiredUnit`](../wiki/TypeAlias.ExpiredUnit) = `'t'`
|
|
30
30
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# Function: WebStorage()
|
|
4
4
|
|
|
5
|
-
> **WebStorage**(`storage`, `key
|
|
5
|
+
> **WebStorage**(`storage`, `key?`, `expiredAt?`, `expiredUnit?`): (`target`, `propertyName`) => `void`
|
|
6
6
|
|
|
7
|
-
Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/decorators/web-storage.ts#L16)
|
|
8
8
|
|
|
9
9
|
**`Internal`**
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/bl
|
|
|
12
12
|
|
|
13
13
|
### storage
|
|
14
14
|
|
|
15
|
-
`
|
|
15
|
+
`Storage` \| `null`
|
|
16
16
|
|
|
17
17
|
### key?
|
|
18
18
|
|
|
@@ -28,18 +28,4 @@ Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/bl
|
|
|
28
28
|
|
|
29
29
|
## Returns
|
|
30
30
|
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
### Parameters
|
|
34
|
-
|
|
35
|
-
#### target
|
|
36
|
-
|
|
37
|
-
`any`
|
|
38
|
-
|
|
39
|
-
#### propertyName
|
|
40
|
-
|
|
41
|
-
`string`
|
|
42
|
-
|
|
43
|
-
### Returns
|
|
44
|
-
|
|
45
|
-
`void`
|
|
31
|
+
(`target`, `propertyName`) => `void`
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **getExpired**(`val`, `unit`): `number`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:72](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:72](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L72)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **stringify**(`value`): `string`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:98](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:98](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L98)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
package/docs/wiki/Home.md
CHANGED
|
@@ -15,15 +15,17 @@ This package provides Angular services and decorators for interacting with web s
|
|
|
15
15
|
|
|
16
16
|
**Add the package to your workspace:**
|
|
17
17
|
```bash
|
|
18
|
-
|
|
18
|
+
npm install @rxap/ngx-memory
|
|
19
19
|
```
|
|
20
|
+
With pnpm or yarn use `pnpm add` or `yarn add` instead of `npm install`.
|
|
21
|
+
|
|
20
22
|
**Install peer dependencies:**
|
|
21
23
|
```bash
|
|
22
|
-
|
|
24
|
+
npm install @angular/core
|
|
23
25
|
```
|
|
24
26
|
**Execute the init generator:**
|
|
25
27
|
```bash
|
|
26
|
-
|
|
28
|
+
nx g @rxap/ngx-memory:init
|
|
27
29
|
```
|
|
28
30
|
# Generators
|
|
29
31
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# Type Alias: ExpiredUnit
|
|
4
4
|
|
|
5
|
-
> **ExpiredUnit
|
|
5
|
+
> **ExpiredUnit** = `"s"` \| `"m"` \| `"h"` \| `"d"` \| `"w"` \| `"y"` \| `"t"`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:11](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:11](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L11)
|
|
8
8
|
|
|
9
9
|
Expiration time unit
|
|
10
10
|
s: seconds
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> `const` **isBrowser**: `boolean`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:18](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:18](https://gitlab.com/rxap/packages/-/blob/73459044d95e79d1cc84f9d21f658812d63c3185/packages/angular/memory/src/lib/storage-utility.ts#L18)
|
|
8
8
|
|
|
9
9
|
Determining if an Angular application is rendered in the browser
|
|
10
10
|
The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.
|
package/docs/wiki/globals.md
CHANGED
package/generators.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"init": {
|
|
4
|
+
"factory": "./src/generators/init/generator",
|
|
5
|
+
"schema": "./src/generators/init/schema.json",
|
|
6
|
+
"description": "Initialize the package in the workspace"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"schematics": {
|
|
10
|
+
"init": {
|
|
11
|
+
"factory": "./src/generators/init/index",
|
|
12
|
+
"schema": "./src/generators/init/schema.json",
|
|
13
|
+
"description": "Initialize the package in the workspace"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "22.0.0-dev.
|
|
2
|
+
"version": "22.0.0-dev.2",
|
|
3
3
|
"name": "@rxap/ngx-memory",
|
|
4
4
|
"description": "This package provides Angular services and decorators for interacting with web storage (localStorage and sessionStorage) and in-memory storage. It offers a simple way to manage data persistence with expiration options and provides decorators for binding class properties directly to storage values. The package includes services for local storage, session storage, and ephemeral (in-memory) storage.\n",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@nx/devkit": "24.0.6",
|
|
8
|
-
"tslib": "2.
|
|
8
|
+
"tslib": "2.9.1"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@angular/core": "^22.
|
|
11
|
+
"@angular/core": "^22.0.0"
|
|
12
12
|
},
|
|
13
13
|
"author": {
|
|
14
14
|
"name": "Merzough Münker",
|
|
@@ -42,8 +42,7 @@
|
|
|
42
42
|
]
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
|
-
"access": "public"
|
|
46
|
-
"directory": "../../../dist/packages/angular/memory"
|
|
45
|
+
"access": "public"
|
|
47
46
|
},
|
|
48
47
|
"repository": {
|
|
49
48
|
"type": "git",
|
|
@@ -61,8 +60,7 @@
|
|
|
61
60
|
".": {
|
|
62
61
|
"types": "./types/rxap-ngx-memory.d.ts",
|
|
63
62
|
"default": "./fesm2022/rxap-ngx-memory.mjs"
|
|
64
|
-
}
|
|
65
|
-
"./theme": "./theme.css"
|
|
63
|
+
}
|
|
66
64
|
},
|
|
67
65
|
"type": "module"
|
|
68
|
-
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initGenerator = initGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the directory of a package installed in the workspace. The lookup starts at the
|
|
9
|
+
* workspace root, not at this package: with an isolated node_modules layout (pnpm) or Yarn PnP
|
|
10
|
+
* the peer is not resolvable from here. The plain node_modules path is the fallback for packages
|
|
11
|
+
* whose `exports` map hides their package.json.
|
|
12
|
+
*/
|
|
13
|
+
function resolvePackageDir(root, packageName) {
|
|
14
|
+
try {
|
|
15
|
+
return (0, path_1.dirname)(require.resolve(`${packageName}/package.json`, { paths: [root] }));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return (0, path_1.join)(root, 'node_modules', ...packageName.split('/'));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function initGenerator(tree, options) {
|
|
22
|
+
// The package's own package.json lives on disk next to the compiled generator
|
|
23
|
+
// (inside node_modules when installed), which the virtual Tree does not track.
|
|
24
|
+
// Read it directly from the physical filesystem.
|
|
25
|
+
const packageJsonFilePath = (0, path_1.join)(__dirname, '..', '..', '..', 'package.json');
|
|
26
|
+
if (!(0, fs_1.existsSync)(packageJsonFilePath)) {
|
|
27
|
+
console.error('package.json not found in: ' + packageJsonFilePath);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const { peerDependencies, name: packageName } = JSON.parse((0, fs_1.readFileSync)(packageJsonFilePath, 'utf-8'));
|
|
31
|
+
console.log(`Coerce peer dependencies for package: ${packageName}`);
|
|
32
|
+
if (!peerDependencies || !Object.keys(peerDependencies).length) {
|
|
33
|
+
console.log('No peer dependencies found');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
console.log(`Peer dependencies: ${Object.keys(peerDependencies).join(', ')}`);
|
|
37
|
+
const rootPackageJson = JSON.parse(tree.read('package.json', 'utf-8'));
|
|
38
|
+
let isDevDependency = !!rootPackageJson.devDependencies?.[packageName];
|
|
39
|
+
if (isDevDependency &&
|
|
40
|
+
[/^@rxap\/ngx/, /^@rxap\/nest/].some((rx) => rx.test(packageName))) {
|
|
41
|
+
rootPackageJson.dependencies ??= {};
|
|
42
|
+
rootPackageJson.dependencies[packageName] =
|
|
43
|
+
rootPackageJson.devDependencies[packageName];
|
|
44
|
+
delete rootPackageJson.devDependencies[packageName];
|
|
45
|
+
isDevDependency = false;
|
|
46
|
+
tree.write('package.json', JSON.stringify(rootPackageJson, null, 2));
|
|
47
|
+
}
|
|
48
|
+
if (!isDevDependency &&
|
|
49
|
+
[
|
|
50
|
+
/^@rxap\/plugin/,
|
|
51
|
+
/^@rxap\/workspace/,
|
|
52
|
+
/@rxap\/schematic/,
|
|
53
|
+
].some((rx) => rx.test(packageName))) {
|
|
54
|
+
rootPackageJson.devDependencies ??= {};
|
|
55
|
+
rootPackageJson.devDependencies[packageName] =
|
|
56
|
+
rootPackageJson.dependencies[packageName];
|
|
57
|
+
delete rootPackageJson.dependencies[packageName];
|
|
58
|
+
isDevDependency = true;
|
|
59
|
+
tree.write('package.json', JSON.stringify(rootPackageJson, null, 2));
|
|
60
|
+
}
|
|
61
|
+
const missingPeerDependencies = Object.entries(peerDependencies)
|
|
62
|
+
.filter(([dep]) => !rootPackageJson.dependencies?.[dep] &&
|
|
63
|
+
!rootPackageJson.devDependencies?.[dep])
|
|
64
|
+
.reduce((acc, [dep, version]) => ({ ...acc, [dep]: version }), {});
|
|
65
|
+
if (!Object.keys(missingPeerDependencies).length) {
|
|
66
|
+
console.log('No missing peer dependencies');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (isDevDependency) {
|
|
70
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, missingPeerDependencies);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, missingPeerDependencies, {});
|
|
74
|
+
}
|
|
75
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
76
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
77
|
+
for (const peer of Object.keys(missingPeerDependencies)) {
|
|
78
|
+
console.log(`Peer dependency ${peer} added to package.json`);
|
|
79
|
+
// node_modules is physical and excluded from the virtual Tree, so read the
|
|
80
|
+
// peer files from disk.
|
|
81
|
+
const peerPackageDir = resolvePackageDir(tree.root, peer);
|
|
82
|
+
const peerPackageJsonFilePath = (0, path_1.join)(peerPackageDir, 'package.json');
|
|
83
|
+
if (!(0, fs_1.existsSync)(peerPackageJsonFilePath)) {
|
|
84
|
+
console.log(`Peer dependency ${peer} has no package.json`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const { generators, schematics } = JSON.parse((0, fs_1.readFileSync)(peerPackageJsonFilePath, 'utf-8'));
|
|
88
|
+
if (!generators && !schematics) {
|
|
89
|
+
console.log(`Peer dependency ${peer} has no generators or schematics`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const configFile = generators || schematics;
|
|
93
|
+
const configFilePath = (0, path_1.join)(peerPackageDir, configFile);
|
|
94
|
+
if (!(0, fs_1.existsSync)(configFilePath)) {
|
|
95
|
+
console.log(`Peer dependency ${peer} has no generators or schematics file`);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const config = JSON.parse((0, fs_1.readFileSync)(configFilePath, 'utf-8'));
|
|
99
|
+
if (!config.generators?.init) {
|
|
100
|
+
console.log(`Peer dependency ${peer} has no init generator`);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const initGeneratorFilePath = config.generators.init.factory;
|
|
104
|
+
const fullInitGeneratorFilePath = (0, path_1.join)(peerPackageDir, initGeneratorFilePath) + '.js';
|
|
105
|
+
if (!(0, fs_1.existsSync)(fullInitGeneratorFilePath)) {
|
|
106
|
+
console.log(`Peer dependency ${peer} has no init generator file: ` +
|
|
107
|
+
fullInitGeneratorFilePath);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
111
|
+
const initGenerator = require((0, path_1.join)(peerPackageDir, initGeneratorFilePath))?.default;
|
|
112
|
+
if (typeof initGenerator !== 'function') {
|
|
113
|
+
console.log(`Peer dependency ${peer} has no init generator function`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
console.log(`Run init generator for peer dependency ${peer}`);
|
|
117
|
+
await initGenerator(tree, options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.default = initGenerator;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const generator_1 = require("./generator");
|
|
5
|
+
const schematic = (0, devkit_1.convertNxGenerator)(generator_1.default);
|
|
6
|
+
exports.default = schematic;
|