remediation 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":""}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const commander_1 = require("commander");
37
+ const core_1 = require("@remediation/core");
38
+ const program = new commander_1.Command();
39
+ program
40
+ .name('remediation')
41
+ .description('CLI tool that scans React source code and detects design system inconsistencies')
42
+ .version('0.0.1');
43
+ program
44
+ .command('scan')
45
+ .description('Run all rules (tokens + components)')
46
+ .option('--dry-run', 'Preview mode, do not apply fixes', false)
47
+ .option('--format <format>', 'Output format (terminal, json)', 'terminal')
48
+ .argument('[path]', 'Path to scan', '.')
49
+ .action(async (path, options) => {
50
+ const result = await (0, core_1.scanProject)(path, core_1.allRules);
51
+ if (options.format === 'json') {
52
+ console.log(JSON.stringify(result, null, 2));
53
+ }
54
+ else {
55
+ printTerminal(result);
56
+ }
57
+ if (!options.dryRun && result.summary.total > 0) {
58
+ console.log('\nApplying fixes...');
59
+ const transforms = (0, core_1.getTransformsMap)();
60
+ const { applyTransforms } = await Promise.resolve().then(() => __importStar(require('@remediation/core')));
61
+ const fixes = applyTransforms(result.files.flatMap(f => f.violations), transforms);
62
+ if (fixes.length > 0) {
63
+ console.log(`Fixed ${fixes.length} files`);
64
+ }
65
+ else {
66
+ console.log('No automatic fixes available');
67
+ }
68
+ }
69
+ });
70
+ program
71
+ .command('tokens')
72
+ .description('Check for token inconsistencies')
73
+ .option('--dry-run', 'Preview mode, do not apply fixes', false)
74
+ .option('--format <format>', 'Output format (terminal, json)', 'terminal')
75
+ .argument('[path]', 'Path to scan', '.')
76
+ .action(async (path, options) => {
77
+ const tokenRules = core_1.allRules.filter(r => r.name.startsWith('tokens/'));
78
+ const result = (0, core_1.scanDirectory)(path, tokenRules);
79
+ if (options.format === 'json') {
80
+ console.log(JSON.stringify(result, null, 2));
81
+ }
82
+ else {
83
+ printTerminal(result);
84
+ }
85
+ if (!options.dryRun && result.summary.total > 0) {
86
+ console.log('\nApplying fixes...');
87
+ const transforms = (0, core_1.getTransformsMap)();
88
+ const { applyTransforms } = await Promise.resolve().then(() => __importStar(require('@remediation/core')));
89
+ const fixes = applyTransforms(result.files.flatMap(f => f.violations), transforms);
90
+ if (fixes.length > 0) {
91
+ console.log(`Fixed ${fixes.length} files`);
92
+ }
93
+ else {
94
+ console.log('No automatic fixes available');
95
+ }
96
+ }
97
+ });
98
+ program
99
+ .command('components')
100
+ .description('Check for component issues (duplicates, dead components)')
101
+ .option('--dry-run', 'Preview mode, do not apply fixes', false)
102
+ .option('--format <format>', 'Output format (terminal, json)', 'terminal')
103
+ .argument('[path]', 'Path to scan', '.')
104
+ .action(async (path, options) => {
105
+ const result = await (0, core_1.scanProject)(path, core_1.componentRules);
106
+ if (options.format === 'json') {
107
+ console.log(JSON.stringify(result, null, 2));
108
+ }
109
+ else {
110
+ printTerminal(result);
111
+ }
112
+ if (!options.dryRun && result.summary.total > 0) {
113
+ console.log('\nApplying fixes...');
114
+ const transforms = (0, core_1.getTransformsMap)();
115
+ const { applyTransforms } = await Promise.resolve().then(() => __importStar(require('@remediation/core')));
116
+ const fixes = applyTransforms(result.files.flatMap(f => f.violations), transforms);
117
+ if (fixes.length > 0) {
118
+ console.log(`Fixed ${fixes.length} files`);
119
+ }
120
+ else {
121
+ console.log('No automatic fixes available');
122
+ }
123
+ }
124
+ });
125
+ function printTerminal(result) {
126
+ if (result.files.length === 0) {
127
+ console.log('No violations found');
128
+ return;
129
+ }
130
+ for (const file of result.files) {
131
+ console.log(`\n${file.path}`);
132
+ for (const violation of file.violations) {
133
+ const severity = violation.severity.toUpperCase().padEnd(7);
134
+ console.log(` ${severity} L${violation.line}:${violation.column} ${violation.message}`);
135
+ if (violation.suggestion) {
136
+ console.log(` ${violation.suggestion}`);
137
+ }
138
+ }
139
+ }
140
+ console.log(`\n${result.summary.total} violations (${result.summary.errors} errors, ${result.summary.warnings} warnings, ${result.summary.infos} infos)`);
141
+ console.log(`Risk score: ${result.riskScore}`);
142
+ }
143
+ program.parse();
144
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,4CAA2G;AAE3G,MAAM,OAAO,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C,OAAO,CAAC,MAAM,YAAY,MAAM,CAAC,OAAO,CAAC,QAAQ,cAAc,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC;IAC1J,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import './commands/run';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require("./commands/run");
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,0BAAwB"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "remediation",
3
+ "version": "0.1.0",
4
+ "description": "CLI tool that scans React source code and detects design system inconsistencies",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "remediation": "dist/index.js"
8
+ },
9
+ "main": "dist/index.js",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "dependencies": {
18
+ "@remediation/core": "*",
19
+ "commander": "^12.0.0"
20
+ },
21
+ "devDependencies": {
22
+ "typescript": "^5.0.0"
23
+ },
24
+ "keywords": [
25
+ "react",
26
+ "design-system",
27
+ "tokens",
28
+ "lint",
29
+ "code-quality"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": ""
34
+ }
35
+ }