@o3r/core 10.2.0-prerelease.2 → 10.2.0-prerelease.21
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 +4 -4
- package/schematics/ng-add/component-decorator/index.d.ts +0 -1
- package/schematics/ng-add/component-decorator/index.d.ts.map +1 -1
- package/schematics/ng-add/component-decorator/index.js +3 -4
- package/schematics/ng-add-create/templates/schematics/ng-add/index.ts.template +41 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/core",
|
|
3
|
-
"version": "10.2.0-prerelease.
|
|
3
|
+
"version": "10.2.0-prerelease.21",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@ngrx/store": "~17.1.0",
|
|
27
27
|
"@nrwl/devkit": "~18.0.2",
|
|
28
28
|
"@nx/angular": "~18.0.2",
|
|
29
|
-
"@o3r/telemetry": "^10.2.0-prerelease.
|
|
29
|
+
"@o3r/telemetry": "^10.2.0-prerelease.21",
|
|
30
30
|
"@schematics/angular": "~17.2.0",
|
|
31
31
|
"chokidar": "^3.5.2",
|
|
32
32
|
"globby": "^11.1.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@o3r/schematics": "^10.2.0-prerelease.
|
|
67
|
+
"@o3r/schematics": "^10.2.0-prerelease.21",
|
|
68
68
|
"tslib": "^2.5.3",
|
|
69
69
|
"uuid": "^9.0.0"
|
|
70
70
|
},
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@ngrx/router-store": "~17.1.0",
|
|
75
75
|
"@ngrx/effects": "~17.1.0",
|
|
76
76
|
"@ngrx/store-devtools": "~17.1.0",
|
|
77
|
-
"@o3r/store-sync": "^10.2.0-prerelease.
|
|
77
|
+
"@o3r/store-sync": "^10.2.0-prerelease.21",
|
|
78
78
|
"@types/jest": "~29.5.2",
|
|
79
79
|
"nx": "~18.0.2",
|
|
80
80
|
"@typescript-eslint/parser": "^7.0.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/component-decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAQ,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/component-decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAQ,MAAM,4BAA4B,CAAC;AAyBxD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,IA8DvC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateComponentDecorators = void 0;
|
|
4
|
-
const schematics_1 = require("@o3r/schematics");
|
|
5
4
|
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
6
5
|
const change_1 = require("@schematics/angular/utility/change");
|
|
7
6
|
const ts = require("typescript");
|
|
@@ -16,11 +15,11 @@ const removeImport = (source, symbolName, fileName) => {
|
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
17
|
* Update component file with new decorators for otter devtools
|
|
19
|
-
*
|
|
20
18
|
* @param tree Tree
|
|
21
19
|
*/
|
|
22
|
-
const updateComponentDecorators = (tree) => {
|
|
23
|
-
const
|
|
20
|
+
const updateComponentDecorators = async (tree) => {
|
|
21
|
+
const { getFilesInFolderFromWorkspaceProjectsInTree } = await Promise.resolve().then(() => require('@o3r/schematics'));
|
|
22
|
+
const componentFiles = new Set(getFilesInFolderFromWorkspaceProjectsInTree(tree, '', 'component.ts'));
|
|
24
23
|
componentFiles.forEach((filePath) => {
|
|
25
24
|
const source = ts.createSourceFile(filePath, tree.readText(filePath), ts.ScriptTarget.ES2015, true);
|
|
26
25
|
const recorder = tree.beginUpdate(filePath);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { chain, noop, Rule } from '@angular-devkit/schematics';
|
|
2
2
|
import type { NgAddSchematicsSchema } from './schema';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import type { DependencyToAdd } from '@o3r/schematics';
|
|
5
5
|
|
|
6
6
|
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
7
7
|
|
|
@@ -18,6 +18,13 @@ const dependenciesToNgAdd = [
|
|
|
18
18
|
// Add the dependencies to install with NgAdd here
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
+
const reportMissingSchematicsDep = (logger: { error: (message: string) => any }) => (reason: any) => {
|
|
22
|
+
logger.error(`[ERROR]: Adding <%= featureName %> has failed.
|
|
23
|
+
If the error is related to missing @o3r dependencies you need to install '@o3r/core' to be able to use the <%= featureName %> package. Please run 'ng add @o3r/core' .
|
|
24
|
+
Otherwise, use the error message as guidance.`);
|
|
25
|
+
throw reason;
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
/**
|
|
22
29
|
* Add Otter <%= featureName %> to an Otter Project
|
|
23
30
|
*
|
|
@@ -25,37 +32,38 @@ const dependenciesToNgAdd = [
|
|
|
25
32
|
*/
|
|
26
33
|
function ngAddFn(options: NgAddSchematicsSchema): Rule {
|
|
27
34
|
return async (tree, context) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
]);
|
|
53
|
-
} catch (e) {
|
|
54
|
-
// If the installation is initialized in a non-Otter application, mandatory packages will be missing. We need to notify the user
|
|
55
|
-
context.logger.error(`[ERROR]: Adding <%= featureName %> has failed.
|
|
56
|
-
If the error is related to missing @o3r dependencies you need to install '@o3r/core' to be able to use the <%= featureName %> package. Please run 'ng add @o3r/core' .
|
|
57
|
-
Otherwise, use the error message as guidance.`);
|
|
58
|
-
throw (e);
|
|
59
|
-
}
|
|
35
|
+
// use dynamic import to properly raise an exception if it is not an Otter project.
|
|
36
|
+
const { getProjectNewDependenciesTypes, getPackageInstallConfig, applyEsLintFix, install } = await import('@o3r/schematics');
|
|
37
|
+
// current package version
|
|
38
|
+
const version = JSON.stringify(fs.readFileSync(packageJsonPath)).version;
|
|
39
|
+
const dependencies = [...dependenciesToInstall, ...dependenciesToNgAdd].reduce((acc, dep) => {
|
|
40
|
+
acc[dep] = {
|
|
41
|
+
inManifest: [{
|
|
42
|
+
range: `~${version}`,
|
|
43
|
+
types: getProjectNewDependenciesTypes(workspaceProject)
|
|
44
|
+
}]
|
|
45
|
+
};
|
|
46
|
+
return acc;
|
|
47
|
+
}, getPackageInstallConfig(packageJsonPath, tree, options.projectName));
|
|
48
|
+
return chain([
|
|
49
|
+
// optional custom action dedicated to this module
|
|
50
|
+
doCustomAction,
|
|
51
|
+
options.skipLinter ? noop() : applyEsLintFix(),
|
|
52
|
+
setupDependencies({
|
|
53
|
+
projectName: options.projectName,
|
|
54
|
+
dependencies,
|
|
55
|
+
ngAddToRun: dependenciesToNgAdd,
|
|
56
|
+
skipInstall: options.skipInstall
|
|
57
|
+
})
|
|
58
|
+
]);
|
|
60
59
|
};
|
|
61
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Add module to an Angular Project
|
|
64
|
+
* @param options ng add options
|
|
65
|
+
*/
|
|
66
|
+
export const ngAdd = (options: NgAddSchematicsSchema): Rule => async (_, { logger }) => {
|
|
67
|
+
const { createSchematicWithMetricsIfInstalled } = await import('@o3r/schematics').catch(reportMissingSchematicsDep(logger));
|
|
68
|
+
return createSchematicWithMetricsIfInstalled(ngAddFn)(options);
|
|
69
|
+
};
|