swatchkit 0.8.1 → 0.9.1

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.
Files changed (3) hide show
  1. package/README.md +6 -0
  2. package/build.js +41 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -266,6 +266,8 @@ swatchkit [command] [options]
266
266
  | `--outDir` | `-o` | Output directory (Default: `dist/swatchkit`). |
267
267
  | `--force` | `-f` | Overwrite all init-managed files with latest blueprints. |
268
268
  | `--dry-run` | | Show what init would create or change, without writing anything.|
269
+ | `--help` | `-h` | Show help message. |
270
+ | `--version` | `-v` | Show version number. |
269
271
 
270
272
  ## Configuration
271
273
 
@@ -379,6 +381,10 @@ In watch mode, SwatchKit detects when its output directory is deleted by an exte
379
381
 
380
382
  SwatchKit only ever writes inside its own output subdirectory — it will never modify or delete other files in `dist/`.
381
383
 
384
+ ### Watch mode and file watchers
385
+
386
+ SwatchKit generates files into your source tree during each build — CSS token files (`css/global/tokens.css`, `css/utilities/tokens.css`) and token documentation HTML (`swatchkit/tokens/*.html`). To avoid triggering external file watchers unnecessarily, SwatchKit compares generated content against the existing file and **skips the write when nothing has changed**. This means most rebuilds (e.g., editing an HTML swatch) won't touch your CSS directory at all, preventing infinite rebuild loops when running alongside tools like `onchange`, `chokidar`, or framework dev servers that watch `src/`.
387
+
382
388
  ## Acknowledgements
383
389
 
384
390
  The CSS compositions included by default in SwatchKit are adapted from [Every Layout](https://every-layout.dev/) by Heydon Pickering and Andy Bell. Highly recommend their documentation for a deep dive into their brilliant CSS techniques.
package/build.js CHANGED
@@ -28,6 +28,10 @@ function parseArgs(args) {
28
28
  options.command = "init";
29
29
  } else if (arg === "-w" || arg === "--watch") {
30
30
  options.watch = true;
31
+ } else if (arg === "-h" || arg === "--help") {
32
+ options.command = "help";
33
+ } else if (arg === "-v" || arg === "--version") {
34
+ options.command = "version";
31
35
  } else if (arg === "-f" || arg === "--force") {
32
36
  options.force = true;
33
37
  } else if (arg === "--dry-run") {
@@ -838,9 +842,46 @@ function watch(settings) {
838
842
  }, 2000);
839
843
  }
840
844
 
845
+ // --- 7. Help & Version ---
846
+ function printVersion() {
847
+ const pkg = require(path.join(__dirname, "package.json"));
848
+ console.log(pkg.version);
849
+ }
850
+
851
+ function printHelp() {
852
+ const pkg = require(path.join(__dirname, "package.json"));
853
+ console.log(`SwatchKit v${pkg.version}
854
+
855
+ Usage: swatchkit [command] [options]
856
+
857
+ Commands:
858
+ (default) Build the pattern library
859
+ init Scaffold layout, tokens, and CSS blueprints
860
+
861
+ Options:
862
+ -w, --watch Watch files and rebuild on change
863
+ -c, --config Path to config file
864
+ -i, --input Pattern directory (default: swatchkit/)
865
+ -o, --outDir Output directory (default: dist/swatchkit)
866
+ -f, --force Overwrite all init-managed files with latest blueprints
867
+ --dry-run Show what init would create or change, without writing
868
+ -h, --help Show this help message
869
+ -v, --version Show version number`);
870
+ }
871
+
841
872
  // --- Main Execution ---
842
873
  try {
843
874
  const cliOptions = parseArgs(process.argv);
875
+
876
+ if (cliOptions.command === "help") {
877
+ printHelp();
878
+ process.exit(0);
879
+ }
880
+ if (cliOptions.command === "version") {
881
+ printVersion();
882
+ process.exit(0);
883
+ }
884
+
844
885
  const fileConfig = loadConfig(cliOptions.config);
845
886
  const settings = resolveSettings(cliOptions, fileConfig);
846
887
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swatchkit",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "A lightweight tool for creating HTML pattern libraries.",
5
5
  "main": "build.js",
6
6
  "bin": {