@o3r/schematics 9.4.0-alpha.1 → 9.4.0-alpha.11
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/package.json +4 -4
- package/src/rule-factories/eslint-fix/index.d.ts +1 -17
- package/src/rule-factories/eslint-fix/index.d.ts.map +1 -1
- package/src/rule-factories/eslint-fix/index.js +10 -24
- package/src/rule-factories/eslint-fix/index.js.map +1 -1
- package/src/tasks/eslint/index.d.ts +26 -1
- package/src/tasks/eslint/index.d.ts.map +1 -1
- package/src/tasks/eslint/index.js +15 -5
- package/src/tasks/eslint/index.js.map +1 -1
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<h1 align="center">Otter schematics</h1>
|
2
2
|
<p align="center">
|
3
|
-
<img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main
|
3
|
+
<img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
|
4
4
|
</p>
|
5
5
|
|
6
6
|
This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/otter/tree/main/docs/core/MODULE.md).
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@o3r/schematics",
|
3
|
-
"version": "9.4.0-alpha.
|
3
|
+
"version": "9.4.0-alpha.11",
|
4
4
|
"description": "Schematics module of the Otter framework",
|
5
5
|
"main": "./src/public_api.js",
|
6
6
|
"keywords": [
|
@@ -62,9 +62,9 @@
|
|
62
62
|
"@nx/jest": "~16.8.0",
|
63
63
|
"@nx/js": "~16.8.0",
|
64
64
|
"@nx/linter": "~16.8.0",
|
65
|
-
"@o3r/build-helpers": "^9.4.0-alpha.
|
66
|
-
"@o3r/dev-tools": "^9.4.0-alpha.
|
67
|
-
"@o3r/eslint-plugin": "^9.4.0-alpha.
|
65
|
+
"@o3r/build-helpers": "^9.4.0-alpha.11",
|
66
|
+
"@o3r/dev-tools": "^9.4.0-alpha.11",
|
67
|
+
"@o3r/eslint-plugin": "^9.4.0-alpha.11",
|
68
68
|
"@schematics/angular": "~16.2.0",
|
69
69
|
"@types/jest": "~29.5.2",
|
70
70
|
"@types/node": "^18.0.0",
|
@@ -1,21 +1,5 @@
|
|
1
1
|
import { Rule } from '@angular-devkit/schematics';
|
2
|
-
|
3
|
-
* Linter options
|
4
|
-
*/
|
5
|
-
export interface LinterOptions {
|
6
|
-
/**
|
7
|
-
* Indicates if the linter process should succeed even if there are lint errors remaining
|
8
|
-
*
|
9
|
-
* @default true
|
10
|
-
*/
|
11
|
-
force?: boolean;
|
12
|
-
/**
|
13
|
-
* If enabled, only errors are reported (--quiet option of ESLint CLI)
|
14
|
-
*
|
15
|
-
* @default true
|
16
|
-
*/
|
17
|
-
hideWarnings?: boolean;
|
18
|
-
}
|
2
|
+
import { LinterOptions } from '../../tasks';
|
19
3
|
/**
|
20
4
|
* Apply EsLint fix
|
21
5
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/eslint-fix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,IAAI,EAA0B,MAAM,4BAA4B,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/rule-factories/eslint-fix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAEpF,OAAO,EAAiB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,UAAU,SAAM,EAAE,SAAS,GAAE,MAAM,EAAW,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CA6D5G"}
|
@@ -1,9 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.applyEsLintFix = void 0;
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
5
4
|
const node_path_1 = require("node:path");
|
6
|
-
const
|
5
|
+
const tasks_1 = require("../../tasks");
|
7
6
|
/**
|
8
7
|
* Apply EsLint fix
|
9
8
|
*
|
@@ -14,15 +13,17 @@ const package_manager_runner_1 = require("../../utility/package-manager-runner")
|
|
14
13
|
*/
|
15
14
|
function applyEsLintFix(_prootPath = '/', extension = ['ts'], options) {
|
16
15
|
const linterOptions = {
|
16
|
+
continueOnError: options?.force ?? true,
|
17
17
|
force: true,
|
18
18
|
hideWarnings: true,
|
19
19
|
...options
|
20
20
|
};
|
21
21
|
return (tree, context) => {
|
22
|
+
const filesToBeLint = tree.actions
|
23
|
+
.filter((a) => a.kind !== 'd')
|
24
|
+
.map((action) => action.path.substring(1));
|
22
25
|
// directory of the deepest file
|
23
|
-
let dir = tree.getDir((0, node_path_1.dirname)(
|
24
|
-
.map((action) => action.path.substr(1))
|
25
|
-
.reduce((acc, path) => {
|
26
|
+
let dir = tree.getDir((0, node_path_1.dirname)(filesToBeLint.reduce((acc, path) => {
|
26
27
|
const level = path.split('/').length;
|
27
28
|
if (acc.level < level) {
|
28
29
|
return { level, path };
|
@@ -33,7 +34,7 @@ function applyEsLintFix(_prootPath = '/', extension = ['ts'], options) {
|
|
33
34
|
do {
|
34
35
|
eslintFile = dir.subfiles.find((f) => f.startsWith('.eslintrc'));
|
35
36
|
if (eslintFile) {
|
36
|
-
eslintFile = (0, node_path_1.join)(dir.path.
|
37
|
+
eslintFile = (0, node_path_1.join)(dir.path.substring(1), eslintFile);
|
37
38
|
break;
|
38
39
|
}
|
39
40
|
dir = dir.parent;
|
@@ -42,28 +43,13 @@ function applyEsLintFix(_prootPath = '/', extension = ['ts'], options) {
|
|
42
43
|
context.logger.warn(`Asked to run lint fixes, but could not find a eslintrc config file.
|
43
44
|
You can consider to run later the following command to add otter linter rules: ng add @o3r/eslint-config-otter`);
|
44
45
|
}
|
45
|
-
const files =
|
46
|
-
|
47
|
-
if (extension.some((ext) => filePath.endsWith(`.${ext}`)) && dir && action.path.startsWith(dir.path)) {
|
46
|
+
const files = filesToBeLint.reduce((acc, filePath) => {
|
47
|
+
if (extension.some((ext) => filePath.endsWith(`.${ext}`)) && dir && filePath.startsWith(dir.path)) {
|
48
48
|
acc.add(filePath);
|
49
49
|
}
|
50
50
|
return acc;
|
51
51
|
}, new Set());
|
52
|
-
|
53
|
-
(0, node_child_process_1.exec)(`${(0, package_manager_runner_1.getPackageManagerExecutor)()} eslint ` +
|
54
|
-
Array.from(files).map((file) => `"${file}"`).join(' ') +
|
55
|
-
' --fix --color' +
|
56
|
-
(linterOptions.hideWarnings ? ' --quiet' : '') +
|
57
|
-
(eslintFile ? ` --config ${eslintFile} --parser-options=tsconfigRootDir:${(0, node_path_1.resolve)(process.cwd(), (0, node_path_1.dirname)(eslintFile))}` : ''), (_error, stdout, stderr) => {
|
58
|
-
context.logger.info(stdout);
|
59
|
-
if (!linterOptions.force) {
|
60
|
-
context.logger.error(stderr);
|
61
|
-
}
|
62
|
-
});
|
63
|
-
}
|
64
|
-
catch {
|
65
|
-
context.logger.error('Could not run eslint');
|
66
|
-
}
|
52
|
+
context.addTask(new tasks_1.EslintFixTask(Array.from(files), undefined, eslintFile, linterOptions));
|
67
53
|
return tree;
|
68
54
|
};
|
69
55
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rule-factories/eslint-fix/index.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rule-factories/eslint-fix/index.ts"],"names":[],"mappings":";;;AACA,yCAA0C;AAC1C,uCAA2D;AAE3D;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,UAAU,GAAG,GAAG,EAAE,YAAsB,CAAC,IAAI,CAAC,EAAE,OAAuB;IACpG,MAAM,aAAa,GAAkB;QACnC,eAAe,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;QACvC,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,GAAG,OAAO;KACX,CAA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AAI,CAAC;+GACqF,CAAC,CAAC;SAC5G;QAED,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,GAAgB,EAAE,QAAQ,EAAE,EAAE;YAChE,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACjG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aACnB;YAED,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;QAEtB,OAAO,CAAC,OAAO,CACb,IAAI,qBAAa,CACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EACjB,SAAS,EACT,UAAU,EACV,aAAa,CACd,CACF,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AA7DD,wCA6DC"}
|
@@ -1,10 +1,35 @@
|
|
1
1
|
import { TaskConfiguration, TaskConfigurationGenerator } from '@angular-devkit/schematics';
|
2
2
|
import { NodePackageTaskOptions } from '@angular-devkit/schematics/tasks/package-manager/options';
|
3
|
+
/**
|
4
|
+
* Linter options
|
5
|
+
*/
|
6
|
+
export interface LinterOptions {
|
7
|
+
/**
|
8
|
+
* Indicates if the linter process should succeed even if there are lint errors remaining
|
9
|
+
*
|
10
|
+
* @default true
|
11
|
+
* @deprecated will be removed in v10, please use `continueOnError`
|
12
|
+
*/
|
13
|
+
force?: boolean;
|
14
|
+
/**
|
15
|
+
* Indicates if the linter process should succeed even if there are lint errors remaining
|
16
|
+
*
|
17
|
+
* @default true
|
18
|
+
*/
|
19
|
+
continueOnError?: boolean;
|
20
|
+
/**
|
21
|
+
* If enabled, only errors are reported (--quiet option of ESLint CLI)
|
22
|
+
*
|
23
|
+
* @default true
|
24
|
+
*/
|
25
|
+
hideWarnings?: boolean;
|
26
|
+
}
|
3
27
|
export declare class EslintFixTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
|
4
28
|
files: string[];
|
5
29
|
workingDirectory?: string | undefined;
|
6
30
|
configFile?: string | undefined;
|
7
|
-
|
31
|
+
linterOptions: LinterOptions;
|
32
|
+
constructor(files: string[], workingDirectory?: string | undefined, configFile?: string | undefined, options?: LinterOptions);
|
8
33
|
toConfiguration(): TaskConfiguration<NodePackageTaskOptions>;
|
9
34
|
}
|
10
35
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tasks/eslint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAmB,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tasks/eslint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAmB,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAGnH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,qBAAa,aAAc,YAAW,0BAA0B,CAAC,sBAAsB,CAAC;IAGnE,KAAK,EAAE,MAAM,EAAE;IAAS,gBAAgB,CAAC;IAAiB,UAAU,CAAC;IAFjF,aAAa,EAAE,aAAa,CAAC;gBAEjB,KAAK,EAAE,MAAM,EAAE,EAAS,gBAAgB,CAAC,oBAAQ,EAAS,UAAU,CAAC,oBAAQ,EAAE,OAAO,CAAC,EAAE,aAAa;IASlH,eAAe,IAAI,iBAAiB,CAAC,sBAAsB,CAAC;CAmBpE"}
|
@@ -2,15 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.EslintFixTask = void 0;
|
4
4
|
const options_1 = require("@angular-devkit/schematics/tasks/package-manager/options");
|
5
|
-
const path = require("node:path");
|
6
5
|
const package_manager_runner_1 = require("../../utility/package-manager-runner");
|
7
6
|
class EslintFixTask {
|
8
|
-
constructor(files, workingDirectory, configFile) {
|
7
|
+
constructor(files, workingDirectory, configFile, options) {
|
9
8
|
this.files = files;
|
10
9
|
this.workingDirectory = workingDirectory;
|
11
10
|
this.configFile = configFile;
|
11
|
+
this.linterOptions = {
|
12
|
+
continueOnError: options?.force ?? true,
|
13
|
+
force: true,
|
14
|
+
hideWarnings: true,
|
15
|
+
...options
|
16
|
+
};
|
12
17
|
}
|
13
|
-
// TODO Find a way to catch linter errors without failing the ng add process
|
14
18
|
toConfiguration() {
|
15
19
|
return {
|
16
20
|
name: options_1.NodePackageName,
|
@@ -18,8 +22,14 @@ class EslintFixTask {
|
|
18
22
|
command: 'eslint',
|
19
23
|
quiet: false,
|
20
24
|
workingDirectory: this.workingDirectory,
|
21
|
-
packageName:
|
22
|
-
'
|
25
|
+
packageName: [
|
26
|
+
'eslint',
|
27
|
+
...this.files,
|
28
|
+
'--fix',
|
29
|
+
...(this.linterOptions?.hideWarnings ? ['--quiet'] : []),
|
30
|
+
...(this.configFile ? ['--config', this.configFile] : []),
|
31
|
+
...(this.linterOptions?.continueOnError ?? this.linterOptions?.force ? ['|| exit 0'] : [])
|
32
|
+
].join(' '),
|
23
33
|
packageManager: (0, package_manager_runner_1.getPackageManager)()
|
24
34
|
}
|
25
35
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tasks/eslint/index.ts"],"names":[],"mappings":";;;AACA,sFAAmH;AACnH,
|
1
|
+
{"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