@o3r/schematics 10.0.0-prerelease.104 → 10.0.0-prerelease.105
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@o3r/schematics",
|
3
|
-
"version": "10.0.0-prerelease.
|
3
|
+
"version": "10.0.0-prerelease.105",
|
4
4
|
"publishConfig": {
|
5
5
|
"access": "public"
|
6
6
|
},
|
@@ -30,7 +30,7 @@
|
|
30
30
|
"@angular-devkit/core": "~17.2.0",
|
31
31
|
"@angular-devkit/schematics": "~17.2.0",
|
32
32
|
"@angular/cli": "~17.2.0",
|
33
|
-
"@o3r/telemetry": "^10.0.0-prerelease.
|
33
|
+
"@o3r/telemetry": "^10.0.0-prerelease.105",
|
34
34
|
"@schematics/angular": "~17.2.0",
|
35
35
|
"eslint": "^8.42.0",
|
36
36
|
"rxjs": "^7.8.1",
|
@@ -78,9 +78,9 @@
|
|
78
78
|
"@nx/eslint-plugin": "~18.0.2",
|
79
79
|
"@nx/jest": "~18.0.2",
|
80
80
|
"@nx/js": "~18.0.2",
|
81
|
-
"@o3r/build-helpers": "^10.0.0-prerelease.
|
82
|
-
"@o3r/eslint-plugin": "^10.0.0-prerelease.
|
83
|
-
"@o3r/telemetry": "^10.0.0-prerelease.
|
81
|
+
"@o3r/build-helpers": "^10.0.0-prerelease.105",
|
82
|
+
"@o3r/eslint-plugin": "^10.0.0-prerelease.105",
|
83
|
+
"@o3r/telemetry": "^10.0.0-prerelease.105",
|
84
84
|
"@schematics/angular": "~17.2.0",
|
85
85
|
"@stylistic/eslint-plugin-ts": "^1.5.4",
|
86
86
|
"@types/jest": "~29.5.2",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AASvD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,EAAE,gBA4DnD,CAAC"}
|
package/src/utility/wrapper.js
CHANGED
@@ -1,21 +1,64 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.createSchematicWithMetricsIfInstalled = void 0;
|
4
|
+
const prompt_1 = require("@angular/cli/src/utilities/prompt");
|
5
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
6
|
+
const node_fs_1 = require("node:fs");
|
7
|
+
const path = require("node:path");
|
8
|
+
const rxjs_1 = require("rxjs");
|
9
|
+
const index_1 = require("../tasks/index");
|
4
10
|
const noopSchematicWrapper = (fn) => fn;
|
5
11
|
/**
|
6
12
|
* Wrapper method of a schematic to retrieve some metrics around the schematic run
|
7
13
|
* if @o3r/telemetry is installed
|
8
14
|
* @param schematicFn
|
9
15
|
*/
|
10
|
-
const createSchematicWithMetricsIfInstalled = (schematicFn) => (opts) => async (
|
16
|
+
const createSchematicWithMetricsIfInstalled = (schematicFn) => (opts) => async (tree, context) => {
|
11
17
|
let wrapper = noopSchematicWrapper;
|
18
|
+
const packageJsonPath = 'package.json';
|
19
|
+
const packageJson = tree.exists(packageJsonPath) ? tree.readJson(packageJsonPath) : {};
|
12
20
|
try {
|
13
21
|
const { createSchematicWithMetrics } = await Promise.resolve().then(() => require('@o3r/telemetry'));
|
14
|
-
|
22
|
+
if (packageJson.config?.o3rMetrics) {
|
23
|
+
wrapper = createSchematicWithMetrics;
|
24
|
+
}
|
15
25
|
}
|
16
26
|
catch (e) {
|
17
27
|
// Do not throw if `@o3r/telemetry is not installed
|
18
|
-
|
28
|
+
if (packageJson.config?.o3rMetrics) {
|
29
|
+
context.logger.warn('`config.o3rMetrics` is set to true in your package.json, please install the telemetry package with `ng add @o3r/telemetry` to enable the collection of metrics.');
|
30
|
+
}
|
31
|
+
else if (context.interactive && packageJson.config?.o3rMetrics !== false) {
|
32
|
+
context.logger.debug('`@o3r/telemetry` is not available.\nAsking to add the dependency\n' + e.toString());
|
33
|
+
const isReplyPositive = await (0, prompt_1.askConfirmation)(`
|
34
|
+
Would you like to share anonymous data about the usage of Otter builders and schematics with the Otter Team at Amadeus ?
|
35
|
+
It will help us to improve our tools.
|
36
|
+
For more details and instructions on how to change these settings, see https://github.com/AmadeusITGroup/otter/blob/main/docs/telemetry/README.md.
|
37
|
+
`, false);
|
38
|
+
if (isReplyPositive) {
|
39
|
+
const version = JSON.parse((0, node_fs_1.readFileSync)(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')).version;
|
40
|
+
context.addTask(new index_1.NodePackageNgAddTask('@o3r/telemetry', {
|
41
|
+
dependencyType: dependencies_1.NodeDependencyType.Dev,
|
42
|
+
version
|
43
|
+
}));
|
44
|
+
await (0, rxjs_1.lastValueFrom)(context.engine.executePostTasks());
|
45
|
+
try {
|
46
|
+
const { createSchematicWithMetrics } = await Promise.resolve().then(() => require('@o3r/telemetry'));
|
47
|
+
wrapper = createSchematicWithMetrics;
|
48
|
+
}
|
49
|
+
catch {
|
50
|
+
// If pnp context package installed in the same process will not be available
|
51
|
+
}
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
context.logger.info('You can activate it at any time by running `ng add @o3r/telemetry`.');
|
55
|
+
packageJson.config ||= {};
|
56
|
+
packageJson.config.o3rMetrics = false;
|
57
|
+
if (tree.exists(packageJsonPath)) {
|
58
|
+
tree.overwrite(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
19
62
|
}
|
20
63
|
return wrapper(schematicFn)(opts);
|
21
64
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":";;;AACA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