@o3r/schematics 10.1.0-prerelease.2 → 10.1.0-prerelease.21
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +8 -6
- package/schematics/package.json +3 -0
- package/src/rule-factories/ng-add/dependencies.d.ts +15 -1
- package/src/rule-factories/ng-add/dependencies.d.ts.map +1 -1
- package/src/rule-factories/ng-add/dependencies.js +20 -4
- package/src/rule-factories/ng-add/dependencies.js.map +1 -1
- package/src/utility/update-imports.d.ts.map +1 -1
- package/src/utility/update-imports.js +4 -3
- package/src/utility/update-imports.js.map +1 -1
- package/src/utility/wrapper.d.ts.map +1 -1
- package/src/utility/wrapper.js +55 -39
- package/src/utility/wrapper.js.map +1 -1
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.21",
|
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.21",
|
34
34
|
"@schematics/angular": "~17.2.0",
|
35
35
|
"eslint": "^8.42.0",
|
36
36
|
"rxjs": "^7.8.1",
|
@@ -54,6 +54,7 @@
|
|
54
54
|
"dependencies": {
|
55
55
|
"chalk": "^4.1.2",
|
56
56
|
"globby": "^11.1.0",
|
57
|
+
"inquirer": "~8.2.6",
|
57
58
|
"minimatch": "~9.0.3",
|
58
59
|
"semver": "^7.5.2",
|
59
60
|
"tslib": "^2.5.3"
|
@@ -71,18 +72,19 @@
|
|
71
72
|
"@angular/core": "~17.2.0",
|
72
73
|
"@angular/platform-browser": "~17.2.0",
|
73
74
|
"@angular/platform-browser-dynamic": "~17.2.0",
|
74
|
-
"@babel/core": "~7.
|
75
|
+
"@babel/core": "~7.24.0",
|
75
76
|
"@babel/preset-typescript": "~7.23.0",
|
76
77
|
"@compodoc/compodoc": "^1.1.19",
|
77
78
|
"@nx/eslint": "~18.0.2",
|
78
79
|
"@nx/eslint-plugin": "~18.0.2",
|
79
80
|
"@nx/jest": "~18.0.2",
|
80
81
|
"@nx/js": "~18.0.2",
|
81
|
-
"@o3r/build-helpers": "^10.1.0-prerelease.
|
82
|
-
"@o3r/eslint-plugin": "^10.1.0-prerelease.
|
83
|
-
"@o3r/telemetry": "^10.1.0-prerelease.
|
82
|
+
"@o3r/build-helpers": "^10.1.0-prerelease.21",
|
83
|
+
"@o3r/eslint-plugin": "^10.1.0-prerelease.21",
|
84
|
+
"@o3r/telemetry": "^10.1.0-prerelease.21",
|
84
85
|
"@schematics/angular": "~17.2.0",
|
85
86
|
"@stylistic/eslint-plugin-ts": "^1.5.4",
|
87
|
+
"@types/inquirer": "~8.2.10",
|
86
88
|
"@types/jest": "~29.5.2",
|
87
89
|
"@types/node": "^20.0.0",
|
88
90
|
"@types/semver": "^7.3.13",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Rule, type TaskId, Tree } from '@angular-devkit/schematics';
|
1
|
+
import { Rule, type SchematicContext, type TaskId, Tree } from '@angular-devkit/schematics';
|
2
2
|
import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
|
3
3
|
import { SupportedPackageManagers } from '../../utility';
|
4
4
|
/**
|
@@ -59,7 +59,21 @@ export interface SetupDependenciesOptions {
|
|
59
59
|
runAfterTasks?: TaskId[];
|
60
60
|
/** Callback to run after the task ID is calculated */
|
61
61
|
scheduleTaskCallback?: (taskIds?: TaskId[]) => void;
|
62
|
+
/** Working directory for the installation process only */
|
63
|
+
workingDirectory?: string;
|
62
64
|
}
|
65
|
+
/** Result of the Setup Dependencies task scheduling process */
|
66
|
+
export interface SetupDependenciesResult {
|
67
|
+
/** List of the task ID resulting of the install process */
|
68
|
+
taskIds: TaskId[];
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Determine if the context has information regarding the setup dependencies process
|
72
|
+
* @param context Schematic context
|
73
|
+
*/
|
74
|
+
export declare const hasSetupInformation: (context: SchematicContext) => context is SchematicContext & {
|
75
|
+
setupDependencies: SetupDependenciesResult;
|
76
|
+
};
|
63
77
|
/**
|
64
78
|
* Retrieve the package install configuration
|
65
79
|
* This is a workaround to ng-add to add the dependency to the sub-package
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAa,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAa,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAC9G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAI9E,OAAO,EAAyE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAIhI;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,gCAAgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,+BAA+B;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,eAAe,CAAC,EAAE,OAA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, "__esModule", { value: true });
|
3
|
-
exports.setupDependencies = exports.getPackageInstallConfig = void 0;
|
3
|
+
exports.setupDependencies = exports.getPackageInstallConfig = exports.hasSetupInformation = void 0;
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
5
5
|
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
6
6
|
const path = require("node:path");
|
@@ -8,6 +8,14 @@ const semver = require("semver");
|
|
8
8
|
const utility_1 = require("../../utility");
|
9
9
|
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
10
10
|
const node_fs_1 = require("node:fs");
|
11
|
+
/**
|
12
|
+
* Determine if the context has information regarding the setup dependencies process
|
13
|
+
* @param context Schematic context
|
14
|
+
*/
|
15
|
+
const hasSetupInformation = (context) => {
|
16
|
+
return !!context.setupDependencies;
|
17
|
+
};
|
18
|
+
exports.hasSetupInformation = hasSetupInformation;
|
11
19
|
/**
|
12
20
|
* Retrieve the package install configuration
|
13
21
|
* This is a workaround to ng-add to add the dependency to the sub-package
|
@@ -116,7 +124,9 @@ const setupDependencies = (options) => {
|
|
116
124
|
};
|
117
125
|
const runNgAddSchematics = (_, context) => {
|
118
126
|
const packageManager = options.packageManager || (0, utility_1.getPackageManager)();
|
119
|
-
const installId = isInstallNeeded() ? [
|
127
|
+
const installId = isInstallNeeded() ? [
|
128
|
+
context.addTask(new tasks_1.NodePackageInstallTask({ packageManager, quiet: true, workingDirectory: options.workingDirectory }), options.runAfterTasks)
|
129
|
+
] : undefined;
|
120
130
|
if (installId !== undefined) {
|
121
131
|
context.logger.debug(`Schedule the installation of the workspace (${ngAddToRun.size > 0 ? 'for: ' + [...ngAddToRun].join(', ') : options.skipInstall ? 'skipped' : 'forced'})`);
|
122
132
|
}
|
@@ -125,7 +135,7 @@ const setupDependencies = (options) => {
|
|
125
135
|
return Object.fromEntries(Object.entries({ projectName: options.projectName, ...options.ngAddOptions, ...options.dependencies[packageName].ngAddOptions })
|
126
136
|
.filter(([key]) => !schemaOptions || !!schemaOptions[key]));
|
127
137
|
};
|
128
|
-
const
|
138
|
+
const finalTaskIds = [...ngAddToRun]
|
129
139
|
.map((packageName) => {
|
130
140
|
let schematic;
|
131
141
|
try {
|
@@ -142,8 +152,14 @@ const setupDependencies = (options) => {
|
|
142
152
|
context.logger.debug(`Schedule the schematic ng-add for ${packageName}`);
|
143
153
|
return [...ids, context.addTask(new tasks_1.RunSchematicTask(packageName, 'ng-add', schematicOptions), ids)];
|
144
154
|
}, [...(installId || []), ...(options.runAfterTasks || [])]);
|
155
|
+
if ((0, exports.hasSetupInformation)(context)) {
|
156
|
+
context.setupDependencies.taskIds.push(...finalTaskIds);
|
157
|
+
}
|
158
|
+
else {
|
159
|
+
context.setupDependencies = { taskIds: finalTaskIds };
|
160
|
+
}
|
145
161
|
if (options.scheduleTaskCallback) {
|
146
|
-
options.scheduleTaskCallback(
|
162
|
+
options.scheduleTaskCallback(finalTaskIds);
|
147
163
|
}
|
148
164
|
};
|
149
165
|
return (0, schematics_1.chain)([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/dependencies.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/rule-factories/ng-add/dependencies.ts"],"names":[],"mappings":";;;AAAA,2DAA8G;AAC9G,2EAA8E;AAC9E,kCAAkC;AAElC,iCAAiC;AACjC,2CAAgI;AAChI,4DAA4F;AAC5F,qCAAuC;AA4EvC;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,OAAyB,EAAgF,EAAE;IAC7I,OAAO,CAAC,CAAE,OAAe,CAAC,iBAAiB,CAAC;AAC9C,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEF;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,CAAC,eAAuB,EAAE,IAAU,EAAE,WAAoB,EAAE,iBAA2B,EAAmC,EAAE;IACjK,IAAI,CAAC,WAAW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CAAC,GAAG,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,wBAAgB,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACvG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAE/D,IAAI,IAAA,2BAAmB,EAAC,OAAO,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACL,OAAe,CAAC,iBAAiB,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;YACjE,CAAC;YAED,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBACjC,OAAO,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC;QAEF,OAAO,IAAA,kBAAK,EAAC;YACX,eAAe;YACf,kBAAkB;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AAEJ,CAAC,CAAC;AApIW,QAAA,iBAAiB,qBAoI5B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"update-imports.d.ts","sourceRoot":"","sources":["../../../src/utility/update-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
1
|
+
{"version":3,"file":"update-imports.d.ts","sourceRoot":"","sources":["../../../src/utility/update-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAgBvD,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,CAAC,WAAW,EAAE,MAAM,GAAG;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC5F;AAGD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,CAAC,SAAS,EACzB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,MAAM,EAC5B,UAAU,GAAE,cAAmB,EAC/B,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,UAoG7C"}
|
@@ -31,9 +31,10 @@ function updateImportsInFile(logger, tree, sourceFile, importsRegexp, renamePack
|
|
31
31
|
// We store the import line to be able to remove it afterwards
|
32
32
|
importNodes.push(imp);
|
33
33
|
// We retrieve all the symbols listed in the import statement
|
34
|
-
const namedImport = imp.importClause
|
34
|
+
const namedImport = imp.importClause?.namedBindings;
|
35
|
+
const isTypeOnlyImport = !!imp.importClause && ts.isTypeOnlyImportDeclaration(imp.importClause);
|
35
36
|
const imports = namedImport && ts.isNamedImports(namedImport) ?
|
36
|
-
namedImport.elements.map((element) => ({ symbol: element.getText(), location: importFrom })) :
|
37
|
+
namedImport.elements.map((element) => ({ symbol: element.getText(), isTypeOnlyImport, location: importFrom })) :
|
37
38
|
[];
|
38
39
|
// And associate them to the Otter package
|
39
40
|
oldImportedSymbolsPerPackage[otterPackage].push(...imports);
|
@@ -62,7 +63,7 @@ function updateImportsInFile(logger, tree, sourceFile, importsRegexp, renamePack
|
|
62
63
|
acc[importFrom] = [];
|
63
64
|
}
|
64
65
|
const newNameForExportedValue = mapImports[oldPackageName]?.[importSymbol.symbol]?.newValue;
|
65
|
-
acc[importFrom].push(newNameForExportedValue || importSymbol.symbol);
|
66
|
+
acc[importFrom].push(`${importSymbol.isTypeOnlyImport ? 'type ' : ''}${newNameForExportedValue || importSymbol.symbol}`);
|
66
67
|
});
|
67
68
|
return acc;
|
68
69
|
}, {});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"update-imports.js","sourceRoot":"","sources":["../../../src/utility/update-imports.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,qEAAkE;
|
1
|
+
{"version":3,"file":"update-imports.js","sourceRoot":"","sources":["../../../src/utility/update-imports.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,qEAAkE;AAuBlE;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CACjC,MAAyB,EACzB,IAAU,EACV,UAAyB,EACzB,aAAqB,EACrB,oBAA4B,EAC5B,aAA6B,EAAE,EAC/B,kBAA0C,EAAE;IAE5C,MAAM,4BAA4B,GAAsC,EAAE,CAAC;IAC3E,MAAM,iBAAiB,GAAsB,EAAE,CAAC;IAChD,MAAM,WAAW,GAA2B,EAAE,CAAC;IAE/C,6FAA6F;IAC7F,IAAA,qBAAS,EAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrE,MAAM,GAAG,GAAG,OAA+B,CAAC;QAC5C,MAAM,UAAU,GAAG,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAEtE,MAAM,kBAAkB,GAAG,UAAU,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAElE,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAErF,yCAAyC;QACzC,IAAI,YAAY,EAAE,CAAC;YAEjB,IAAI,CAAC,4BAA4B,C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AEnC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAEjD,gFAAgF;IAChF,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,wBAAwB,UAAU,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAClF,iBAAiB,CAAC,OAAO,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,gBAAgB,CAAC,MAAM,kBAAkB,gBAAgB,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IACvJ,CAAC;IAED,OAAO,iBAAiB,CAAC,MAAM,CAAC;AAClC,CAAC;AA3GD,kDA2GC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAyCvD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,EAAE,gBA0CnD,CAAC"}
|
package/src/utility/wrapper.js
CHANGED
@@ -1,13 +1,40 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.createSchematicWithMetricsIfInstalled = void 0;
|
4
|
-
const
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
5
5
|
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
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) => {
|
13
|
+
if (tree.exists(PACKAGE_JSON_PATH)) {
|
14
|
+
const packageJson = tree.readJson(PACKAGE_JSON_PATH);
|
15
|
+
packageJson.config ||= {};
|
16
|
+
packageJson.config.o3rMetrics = activated;
|
17
|
+
tree.overwrite(PACKAGE_JSON_PATH, JSON.stringify(packageJson, null, 2));
|
18
|
+
}
|
19
|
+
};
|
20
|
+
const setupTelemetry = ({ workingDirectory, runNgAdd }) => (_, context) => {
|
21
|
+
const taskIdsFromContext = (0, rule_factories_1.hasSetupInformation)(context) ? context.setupDependencies.taskIds : undefined;
|
22
|
+
const version = JSON.parse((0, node_fs_1.readFileSync)(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')).version;
|
23
|
+
return (0, rule_factories_1.setupDependencies)({
|
24
|
+
dependencies: {
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
26
|
+
'@o3r/telemetry': {
|
27
|
+
inManifest: [{
|
28
|
+
range: `~${version}`,
|
29
|
+
types: [dependencies_1.NodeDependencyType.Dev]
|
30
|
+
}]
|
31
|
+
}
|
32
|
+
},
|
33
|
+
ngAddToRun: runNgAdd ? ['@o3r/telemetry'] : [],
|
34
|
+
runAfterTasks: taskIdsFromContext,
|
35
|
+
workingDirectory
|
36
|
+
});
|
37
|
+
};
|
11
38
|
/**
|
12
39
|
* Wrapper method of a schematic to retrieve some metrics around the schematic run
|
13
40
|
* if @o3r/telemetry is installed
|
@@ -15,54 +42,43 @@ const noopSchematicWrapper = (fn) => fn;
|
|
15
42
|
*/
|
16
43
|
const createSchematicWithMetricsIfInstalled = (schematicFn) => (opts) => async (tree, context) => {
|
17
44
|
let wrapper = noopSchematicWrapper;
|
18
|
-
|
19
|
-
const packageJson = tree.exists(
|
45
|
+
let shouldInstallTelemetry;
|
46
|
+
const packageJson = tree.exists(PACKAGE_JSON_PATH) ? tree.readJson(PACKAGE_JSON_PATH) : {};
|
20
47
|
try {
|
21
48
|
const { createSchematicWithMetrics } = await Promise.resolve().then(() => require('@o3r/telemetry'));
|
22
|
-
|
23
|
-
wrapper = createSchematicWithMetrics;
|
24
|
-
}
|
49
|
+
wrapper = createSchematicWithMetrics;
|
25
50
|
}
|
26
51
|
catch (e) {
|
27
52
|
// 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')
|
53
|
+
if ((process.env.NX_CLI_SET !== 'true' || process.env.NX_INTERACTIVE === 'true')
|
32
54
|
&& context.interactive
|
33
|
-
&& packageJson.config?.o3rMetrics
|
55
|
+
&& typeof packageJson.config?.o3rMetrics === 'undefined'
|
56
|
+
&& process.env.O3R_METRICS !== 'false'
|
57
|
+
&& opts.o3rMetrics !== false
|
58
|
+
&& (!process.env.CI || process.env.CI === 'false')) {
|
34
59
|
context.logger.debug('`@o3r/telemetry` is not available.\nAsking to add the dependency\n' + e.toString());
|
35
|
-
const
|
60
|
+
const question = {
|
61
|
+
type: 'confirm',
|
62
|
+
name: 'isReplyPositive',
|
63
|
+
message: `
|
36
64
|
Would you like to share anonymous data about the usage of Otter builders and schematics with the Otter Team at Amadeus ?
|
37
65
|
It will help us to improve our tools.
|
38
66
|
For more details and instructions on how to change these settings, see https://github.com/AmadeusITGroup/otter/blob/main/docs/telemetry/README.md.
|
39
|
-
`,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
version
|
45
|
-
}));
|
46
|
-
await (0, rxjs_1.lastValueFrom)(context.engine.executePostTasks());
|
47
|
-
try {
|
48
|
-
const { createSchematicWithMetrics } = await Promise.resolve().then(() => require('@o3r/telemetry'));
|
49
|
-
wrapper = createSchematicWithMetrics;
|
50
|
-
}
|
51
|
-
catch {
|
52
|
-
// If pnp context package installed in the same process will not be available
|
53
|
-
}
|
54
|
-
}
|
55
|
-
else {
|
56
|
-
context.logger.info('You can activate it at any time by running `ng add @o3r/telemetry`.');
|
57
|
-
packageJson.config ||= {};
|
58
|
-
packageJson.config.o3rMetrics = false;
|
59
|
-
if (tree.exists(packageJsonPath)) {
|
60
|
-
tree.overwrite(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
61
|
-
}
|
62
|
-
}
|
67
|
+
`,
|
68
|
+
default: false
|
69
|
+
};
|
70
|
+
const { isReplyPositive } = await (0, inquirer_1.prompt)([question]);
|
71
|
+
shouldInstallTelemetry = isReplyPositive;
|
63
72
|
}
|
64
73
|
}
|
65
|
-
|
74
|
+
const subtreeDirectory = context.schematic.description.name === 'typescript-shell' ? opts.directory.split(path.posix.sep).join(path.sep) ?? '' : '';
|
75
|
+
const rule = (0, schematics_1.chain)([
|
76
|
+
typeof shouldInstallTelemetry !== 'undefined' ? (0, schematics_1.applyToSubtree)(subtreeDirectory, [setupO3rMetricsInPackageJson(!!shouldInstallTelemetry)]) : (0, schematics_1.noop)(),
|
77
|
+
schematicFn(opts),
|
78
|
+
shouldInstallTelemetry ? (0, schematics_1.applyToSubtree)(subtreeDirectory, [setupTelemetry({ workingDirectory: subtreeDirectory || undefined, runNgAdd: !subtreeDirectory })]) : (0, schematics_1.noop)(),
|
79
|
+
typeof shouldInstallTelemetry !== 'undefined' && subtreeDirectory ? (0, schematics_1.applyToSubtree)(subtreeDirectory, [setupO3rMetricsInPackageJson(shouldInstallTelemetry)]) : (0, schematics_1.noop)()
|
80
|
+
]);
|
81
|
+
return wrapper(() => rule)(opts);
|
66
82
|
};
|
67
83
|
exports.createSchematicWithMetricsIfInstalled = createSchematicWithMetricsIfInstalled;
|
68
84
|
//# sourceMappingURL=wrapper.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/utility/wrapper.ts"],"names":[],"mappings":";;;AACA,2DAAoF;AAEpF,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,EAAE;IACzF,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,GAAoE,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;IACzI,MAAM,kBAAkB,GAAG,IAAA,oCAAmB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACxG,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,OA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