Skip to content

Commit 89ba53b

Browse files
committed
make it as cli command
1 parent 3671db4 commit 89ba53b

5 files changed

Lines changed: 27 additions & 3 deletions

File tree

bin/stencil-attributes-analyzer.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
import 'colors';
3+
import path from 'path';
4+
import program from '../lib/commander.js';
5+
import StencilContextAnalyzer from '../lib/StencilContextAnalyzer.js';
6+
import { THEME_PATH, PACKAGE_INFO } from '../constants.js';
7+
import { printCliResultErrorAndExit } from '../lib/cliCommon.js';
8+
9+
program
10+
.version(PACKAGE_INFO.version)
11+
.option(
12+
'-p, --path [path]',
13+
'path where to save the output file (default: ./stencil-context.json)',
14+
'./stencil-context.json',
15+
)
16+
.parse(process.argv);
17+
const cliOptions = program.opts();
18+
19+
new StencilContextAnalyzer(path.join(THEME_PATH, 'templates'))
20+
.analyzeAndExport(cliOptions.path)
21+
.catch(printCliResultErrorAndExit);

bin/stencil.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ program
1515
.command('pull', 'Pulls currently active theme config files and overwrites local copy')
1616
.command('download', 'Downloads all the theme files')
1717
.command('debug', 'Prints environment and theme settings for debug purposes')
18-
.command('scss-autofix', 'Prints environment and theme settings for debug purposes')
18+
.command('scss-autofix', 'Autofix SCSS files in the current directory')
19+
.command('attributes-analyzer', 'Generates a report of all attributes used in the theme')
1920
.parse(process.argv);

lib/StencilContextAnalyzer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class StencilContextAnalyzer {
7777

7878
// Check if we're already processing this template (circular reference)
7979
if (this.processingStack.has(templatePath)) {
80-
console.warn(`Warning: Circular reference detected for template ${templatePath}`);
80+
// console.warn(`Warning: Circular reference detected for template ${templatePath}`);
8181
return;
8282
}
8383

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"stencil-start": "./bin/stencil-start.js",
2626
"stencil-release": "./bin/stencil-release.js",
2727
"stencil-debug": "./bin/stencil-debug.js",
28-
"stencil-scss-autofix": "./bin/stencil-scss-autofix.js"
28+
"stencil-scss-autofix": "./bin/stencil-scss-autofix.js",
29+
"stencil-attributes-analyzer": "./bin/stencil-attributes-analyzer.js"
2930
},
3031
"config": {
3132
"stencil_version": "1.0"

0 commit comments

Comments
 (0)