forgecss 0.1.3 → 0.1.5

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 (4) hide show
  1. package/cli.js +6 -2
  2. package/index.d.ts +5 -10
  3. package/index.js +11 -21
  4. package/package.json +1 -1
package/cli.js CHANGED
@@ -31,7 +31,7 @@ async function runForgeCSS(lookAtPath = null) {
31
31
  // The very first run
32
32
  config = await loadConfig(options.config);
33
33
  if (options.watch) {
34
- const watcher = chokidar.watch([config.styles.sourceDir, config.ui.sourceDir], {
34
+ const watcher = chokidar.watch(config.source, {
35
35
  persistent: true,
36
36
  ignoreInitial: true,
37
37
  ignored: (p, stats) => {
@@ -52,7 +52,11 @@ async function runForgeCSS(lookAtPath = null) {
52
52
  }
53
53
  }
54
54
  }
55
- ForgeCSS(config).parse(lookAtPath);
55
+ ForgeCSS(config).parse(lookAtPath).then(() => {
56
+ if (options.verbose) {
57
+ console.log(`forgecss: CSS generation at ${config.output} completed.`);
58
+ }
59
+ });
56
60
  }
57
61
 
58
62
  runForgeCSS();
package/index.d.ts CHANGED
@@ -1,13 +1,8 @@
1
1
  export type ForgeCSSOptions = {
2
- styles: {
3
- sourceDir: string;
4
- match?: string[];
5
- };
6
- ui: {
7
- sourceDir: string;
8
- match?: string[];
9
- attributes?: string[];
10
- };
2
+ source: string;
3
+ stylesMatch?: string[];
4
+ declarationsMatch?: string[];
5
+ declarationsMatchAttributes?: string[];
11
6
  mapping: {
12
7
  queries: {
13
8
  [key: string]: {
@@ -15,7 +10,7 @@ export type ForgeCSSOptions = {
15
10
  };
16
11
  };
17
12
  };
18
- output: string
13
+ output: string;
19
14
  };
20
15
 
21
16
  export default function forgecss(options?: ForgeCSSOptions): {
package/index.js CHANGED
@@ -1,18 +1,13 @@
1
1
  import getAllFiles from "./lib/getAllFiles.js";
2
2
  import { extractStyles } from "./lib/styles.js";
3
- import { deleteDeclarations, extractDeclarations, getDeclarations } from "./lib/processFile.js";
3
+ import { deleteDeclarations, extractDeclarations } from "./lib/processFile.js";
4
4
  import { generateOutputCSS } from "./lib/generator.js";
5
5
 
6
6
  const DEFAULT_OPTIONS = {
7
- styles: {
8
- sourceDir: null,
9
- match: ['css']
10
- },
11
- ui: {
12
- sourceDir: null,
13
- match: ["html", "jsx", "tsx"],
14
- attribute: ['class', 'className']
15
- },
7
+ source: null,
8
+ stylesMatch: ['css', 'less', 'scss'],
9
+ declarationsMatch: ['html', 'jsx', 'tsx'],
10
+ declarationsMatchAttributes: ['class', 'className'],
16
11
  mapping: {
17
12
  queries: {}
18
13
  },
@@ -22,16 +17,11 @@ const DEFAULT_OPTIONS = {
22
17
  export default function forgecss(options = { styles: {}, ui: {}, mapping: {}, output: null }) {
23
18
  const config = { ...DEFAULT_OPTIONS };
24
19
 
25
- config.styles = Object.assign({}, DEFAULT_OPTIONS.styles, options.styles || {});
26
- config.ui = Object.assign({}, DEFAULT_OPTIONS.ui, options.ui || {});
27
20
  config.mapping = Object.assign({}, DEFAULT_OPTIONS.mapping, options.mapping || {});
28
21
  config.output = options.output || DEFAULT_OPTIONS.output;
29
22
 
30
- if (!config.styles.sourceDir) {
31
- throw new Error('forgecss: "styles.sourceDir" option is required.');
32
- }
33
- if (!config.ui.sourceDir) {
34
- throw new Error('forgecss: "ui.sourceDir" option is required.');
23
+ if (!config.source) {
24
+ throw new Error('forgecss: "source" option is required.');
35
25
  }
36
26
  if (!config.output) {
37
27
  throw new Error('forgecss: "output" option is required.');
@@ -42,11 +32,11 @@ export default function forgecss(options = { styles: {}, ui: {}, mapping: {}, ou
42
32
  // fetching the styles
43
33
  try {
44
34
  if (lookAtPath) {
45
- if (config.styles.match.includes(lookAtPath.split('.').pop().toLowerCase())) {
35
+ if (config.stylesMatch.includes(lookAtPath.split(".").pop().toLowerCase())) {
46
36
  await extractStyles(lookAtPath);
47
37
  }
48
38
  } else {
49
- let files = await getAllFiles(config.styles.sourceDir, config.styles.match);
39
+ let files = await getAllFiles(config.source, config.stylesMatch);
50
40
  for (let file of files) {
51
41
  await extractStyles(file);
52
42
  }
@@ -57,12 +47,12 @@ export default function forgecss(options = { styles: {}, ui: {}, mapping: {}, ou
57
47
  // fetching the declarations
58
48
  try {
59
49
  if (lookAtPath) {
60
- if (config.ui.match.includes(lookAtPath.split('.').pop().toLowerCase())) {
50
+ if (config.declarationsMatch.includes(lookAtPath.split('.').pop().toLowerCase())) {
61
51
  deleteDeclarations(lookAtPath);
62
52
  await extractDeclarations(lookAtPath);
63
53
  }
64
54
  } else {
65
- let files = await getAllFiles(config.ui.sourceDir, config.ui.match);
55
+ let files = await getAllFiles(config.source, config.declarationsMatch);
66
56
  for (let file of files) {
67
57
  await extractDeclarations(file);
68
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forgecss",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "ForgeCSS turns strings into fully generated responsive CSS using a custom DSL.",
6
6
  "author": "Krasimir Tsonev",