@o3r/schematics 10.1.0-prerelease.12 → 10.1.0-prerelease.14
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.1.0-prerelease.
|
3
|
+
"version": "10.1.0-prerelease.14",
|
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.1.0-prerelease.
|
33
|
+
"@o3r/telemetry": "^10.1.0-prerelease.14",
|
34
34
|
"@schematics/angular": "~17.2.0",
|
35
35
|
"eslint": "^8.42.0",
|
36
36
|
"rxjs": "^7.8.1",
|
@@ -79,9 +79,9 @@
|
|
79
79
|
"@nx/eslint-plugin": "~18.0.2",
|
80
80
|
"@nx/jest": "~18.0.2",
|
81
81
|
"@nx/js": "~18.0.2",
|
82
|
-
"@o3r/build-helpers": "^10.1.0-prerelease.
|
83
|
-
"@o3r/eslint-plugin": "^10.1.0-prerelease.
|
84
|
-
"@o3r/telemetry": "^10.1.0-prerelease.
|
82
|
+
"@o3r/build-helpers": "^10.1.0-prerelease.14",
|
83
|
+
"@o3r/eslint-plugin": "^10.1.0-prerelease.14",
|
84
|
+
"@o3r/telemetry": "^10.1.0-prerelease.14",
|
85
85
|
"@schematics/angular": "~17.2.0",
|
86
86
|
"@stylistic/eslint-plugin-ts": "^1.5.4",
|
87
87
|
"@types/inquirer": "~8.2.10",
|
@@ -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;AA2CvD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,EAAE,gBAuCnD,CAAC"}
|
package/src/utility/wrapper.js
CHANGED
@@ -1,13 +1,42 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.createSchematicWithMetricsIfInstalled = void 0;
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
4
5
|
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
5
6
|
const inquirer_1 = require("inquirer");
|
6
7
|
const node_fs_1 = require("node:fs");
|
7
8
|
const path = require("node:path");
|
8
|
-
const
|
9
|
-
const index_1 = require("../tasks/index");
|
9
|
+
const rule_factories_1 = require("../rule-factories");
|
10
10
|
const noopSchematicWrapper = (fn) => fn;
|
11
|
+
const PACKAGE_JSON_PATH = 'package.json';
|
12
|
+
const setupO3rMetricsInPackageJson = (activated) => (tree, context) => {
|
13
|
+
if (!activated) {
|
14
|
+
context.logger.info('You can activate it at any time by running `ng add @o3r/telemetry`.');
|
15
|
+
}
|
16
|
+
if (tree.exists(PACKAGE_JSON_PATH)) {
|
17
|
+
const packageJson = tree.readJson(PACKAGE_JSON_PATH);
|
18
|
+
packageJson.config ||= {};
|
19
|
+
packageJson.config.o3rMetrics = activated;
|
20
|
+
tree.overwrite(PACKAGE_JSON_PATH, JSON.stringify(packageJson, null, 2));
|
21
|
+
}
|
22
|
+
};
|
23
|
+
const setupTelemetry = (_, context) => {
|
24
|
+
const taskIdsFromContext = (0, rule_factories_1.hasSetupInformation)(context) ? context.setupDependencies.taskIds : undefined;
|
25
|
+
const version = JSON.parse((0, node_fs_1.readFileSync)(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')).version;
|
26
|
+
return (0, rule_factories_1.setupDependencies)({
|
27
|
+
dependencies: {
|
28
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
29
|
+
'@o3r/telemetry': {
|
30
|
+
inManifest: [{
|
31
|
+
range: `~${version}`,
|
32
|
+
types: [dependencies_1.NodeDependencyType.Dev]
|
33
|
+
}]
|
34
|
+
}
|
35
|
+
},
|
36
|
+
ngAddToRun: ['@o3r/telemetry'],
|
37
|
+
runAfterTasks: taskIdsFromContext
|
38
|
+
});
|
39
|
+
};
|
11
40
|
/**
|
12
41
|
* Wrapper method of a schematic to retrieve some metrics around the schematic run
|
13
42
|
* if @o3r/telemetry is installed
|
@@ -15,22 +44,20 @@ const noopSchematicWrapper = (fn) => fn;
|
|
15
44
|
*/
|
16
45
|
const createSchematicWithMetricsIfInstalled = (schematicFn) => (opts) => async (tree, context) => {
|
17
46
|
let wrapper = noopSchematicWrapper;
|
18
|
-
|
19
|
-
const packageJson = tree.exists(
|
47
|
+
let shouldInstallTelemetry = false;
|
48
|
+
const packageJson = tree.exists(PACKAGE_JSON_PATH) ? tree.readJson(PACKAGE_JSON_PATH) : {};
|
20
49
|
try {
|
21
50
|
const { createSchematicWithMetrics } = await Promise.resolve().then(() => require('@o3r/telemetry'));
|
22
|
-
|
23
|
-
wrapper = createSchematicWithMetrics;
|
24
|
-
}
|
51
|
+
wrapper = createSchematicWithMetrics;
|
25
52
|
}
|
26
53
|
catch (e) {
|
27
54
|
// Do not throw if `@o3r/telemetry is not installed
|
28
|
-
if (
|
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 ((process.env.NX_CLI_SET !== 'true' || process.env.NX_INTERACTIVE === 'true')
|
55
|
+
if ((process.env.NX_CLI_SET !== 'true' || process.env.NX_INTERACTIVE === 'true')
|
32
56
|
&& context.interactive
|
33
|
-
&& packageJson.config?.o3rMetrics
|
57
|
+
&& typeof packageJson.config?.o3rMetrics === 'undefined'
|
58
|
+
&& process.env.O3R_METRICS !== 'false'
|
59
|
+
&& opts.o3rMetrics !== false
|
60
|
+
&& (!process.env.CI || process.env.CI === 'false')) {
|
34
61
|
context.logger.debug('`@o3r/telemetry` is not available.\nAsking to add the dependency\n' + e.toString());
|
35
62
|
const question = {
|
36
63
|
type: 'confirm',
|
@@ -39,35 +66,19 @@ const createSchematicWithMetricsIfInstalled = (schematicFn) => (opts) => async (
|
|
39
66
|
Would you like to share anonymous data about the usage of Otter builders and schematics with the Otter Team at Amadeus ?
|
40
67
|
It will help us to improve our tools.
|
41
68
|
For more details and instructions on how to change these settings, see https://github.com/AmadeusITGroup/otter/blob/main/docs/telemetry/README.md.
|
42
|
-
|
69
|
+
`,
|
70
|
+
default: false
|
43
71
|
};
|
44
72
|
const { isReplyPositive } = await (0, inquirer_1.prompt)([question]);
|
45
|
-
|
46
|
-
const version = JSON.parse((0, node_fs_1.readFileSync)(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')).version;
|
47
|
-
context.addTask(new index_1.NodePackageNgAddTask('@o3r/telemetry', {
|
48
|
-
dependencyType: dependencies_1.NodeDependencyType.Dev,
|
49
|
-
version
|
50
|
-
}));
|
51
|
-
await (0, rxjs_1.lastValueFrom)(context.engine.executePostTasks());
|
52
|
-
try {
|
53
|
-
const { createSchematicWithMetrics } = await Promise.resolve().then(() => require('@o3r/telemetry'));
|
54
|
-
wrapper = createSchematicWithMetrics;
|
55
|
-
}
|
56
|
-
catch {
|
57
|
-
// If pnp context package installed in the same process will not be available
|
58
|
-
}
|
59
|
-
}
|
60
|
-
else {
|
61
|
-
context.logger.info('You can activate it at any time by running `ng add @o3r/telemetry`.');
|
62
|
-
packageJson.config ||= {};
|
63
|
-
packageJson.config.o3rMetrics = false;
|
64
|
-
if (tree.exists(packageJsonPath)) {
|
65
|
-
tree.overwrite(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
66
|
-
}
|
67
|
-
}
|
73
|
+
shouldInstallTelemetry = isReplyPositive;
|
68
74
|
}
|
69
75
|
}
|
70
|
-
|
76
|
+
const rule = (0, schematics_1.chain)([
|
77
|
+
setupO3rMetricsInPackageJson(shouldInstallTelemetry),
|
78
|
+
schematicFn(opts),
|
79
|
+
shouldInstallTelemetry ? setupTelemetry : (0, schematics_1.noop)()
|
80
|
+
]);
|
81
|
+
return wrapper(() => rule)(opts);
|
71
82
|
};
|
72
83
|
exports.createSchematicWithMetricsIfInstalled = createSchematicWithMetricsIfInstalled;
|
73
84
|
//# sourceMappingURL=wrapper.js.map
|
@@ -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,2DAAoE;AAEpE,2EAA8E;AAC9E,uCAA4C;AAC5C,qCAAuC;AACvC,kCAAkC;AAClC,sDAA2E;AAE3E,MAAM,oBAAoB,GAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;AAE1D,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEzC,MAAM,4BAA4B,GAAiC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;IAClG,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAe,CAAC;QAEnE,WAAW,CAAC,MAAM,KAAK,EAAE,CAAC;QACzB,WAAW,CAAC,MAAqB,CAAC,UAAU,GAAG,SAAS,CAAC;QAE1D,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,cAAc,GAAS,CAAC,CAAC,EA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