@fluffjs/cli 0.1.9 → 0.1.10

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.
package/Cli.d.ts CHANGED
@@ -23,6 +23,7 @@ export declare class Cli {
23
23
  private serve;
24
24
  private serveTarget;
25
25
  private generateEntryPoint;
26
+ private findAllTsFiles;
26
27
  private findFiles;
27
28
  private matchesPatterns;
28
29
  private matchGlob;
package/Cli.js CHANGED
@@ -196,7 +196,6 @@ Examples:
196
196
  name: targetName,
197
197
  srcDir: `src/${targetName}`,
198
198
  outDir: `dist/${targetName}`,
199
- components: ['**/*.component.ts'],
200
199
  assets: ['**/*.html', '**/*.css']
201
200
  };
202
201
  console.log(`Added target '${targetName}' to fluff.json`);
@@ -214,7 +213,6 @@ Examples:
214
213
  name: targetName,
215
214
  srcDir: 'src',
216
215
  outDir: 'dist',
217
- components: ['**/*.component.ts'],
218
216
  assets: ['**/*.html', '**/*.css']
219
217
  }
220
218
  };
@@ -306,7 +304,7 @@ Examples:
306
304
  }
307
305
  const entryPoint = target.entryPoint
308
306
  ? path.join(srcDir, target.entryPoint)
309
- : this.generateEntryPoint(srcDir, target.components);
307
+ : this.generateEntryPoint(srcDir, target.exclude);
310
308
  let inlineStyles = '';
311
309
  if (target.styles && target.styles.length > 0) {
312
310
  const styleContents = [];
@@ -507,7 +505,7 @@ Examples:
507
505
  }
508
506
  const entryPoint = target.entryPoint
509
507
  ? path.join(srcDir, target.entryPoint)
510
- : this.generateEntryPoint(srcDir, target.components);
508
+ : this.generateEntryPoint(srcDir, target.exclude);
511
509
  let inlineStyles = '';
512
510
  if (target.styles && target.styles.length > 0) {
513
511
  const styleContents = [];
@@ -607,12 +605,12 @@ Examples:
607
605
  console.log(' Press Ctrl+C to stop\n');
608
606
  }
609
607
  }
610
- generateEntryPoint(srcDir, componentPatterns) {
611
- const componentFiles = this.findFiles(srcDir, componentPatterns);
612
- for (const f of componentFiles) {
613
- console.log(` ✓ Component: ${path.relative(srcDir, f)}`);
608
+ generateEntryPoint(srcDir, exclude = []) {
609
+ const tsFiles = this.findAllTsFiles(srcDir, exclude);
610
+ for (const f of tsFiles) {
611
+ console.log(` ✓ ${path.relative(srcDir, f)}`);
614
612
  }
615
- const importDecls = componentFiles.map(f => {
613
+ const importDecls = tsFiles.map(f => {
616
614
  const relativePath = './' + path.relative(srcDir, f)
617
615
  .replace(/\\/g, '/');
618
616
  return t.importDeclaration([], t.stringLiteral(relativePath));
@@ -623,6 +621,28 @@ Examples:
623
621
  fs.writeFileSync(entryPath, entryContent);
624
622
  return entryPath;
625
623
  }
624
+ findAllTsFiles(dir, userExclude = []) {
625
+ const files = [];
626
+ const excludePatterns = ['*.spec.ts', '*.test.ts', '__generated_entry.ts', ...userExclude];
627
+ const walk = (currentDir) => {
628
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
629
+ for (const entry of entries) {
630
+ const fullPath = path.join(currentDir, entry.name);
631
+ if (entry.isDirectory()) {
632
+ walk(fullPath);
633
+ }
634
+ else if (entry.isFile() && entry.name.endsWith('.ts')) {
635
+ const relativePath = path.relative(dir, fullPath).replace(/\\/g, '/');
636
+ const isExcluded = excludePatterns.some(pattern => this.matchGlob(entry.name, pattern) || this.matchGlob(relativePath, pattern));
637
+ if (!isExcluded) {
638
+ files.push(fullPath);
639
+ }
640
+ }
641
+ }
642
+ };
643
+ walk(dir);
644
+ return files;
645
+ }
626
646
  findFiles(dir, patterns) {
627
647
  const files = [];
628
648
  const walk = (currentDir) => {
@@ -287,7 +287,7 @@ export default function reactivePlugin() {
287
287
  constructorStatements.push(t.expressionStatement(t.unaryExpression('void', t.memberExpression(t.thisExpression(), t.identifier(methodName)))));
288
288
  for (const prop of mProps) {
289
289
  if (reactiveProps.has(prop)) {
290
- constructorStatements.push(t.expressionStatement(t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(`__${prop}`)), t.identifier('onChange')), t.identifier('subscribe')), [t.arrowFunctionExpression([], t.callExpression(t.memberExpression(t.thisExpression(), t.identifier(methodName)), []))])));
290
+ constructorStatements.push(t.expressionStatement(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('__baseSubscriptions')), t.identifier('push')), [t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(`__${prop}`)), t.identifier('onChange')), t.identifier('subscribe')), [t.arrowFunctionExpression([], t.callExpression(t.memberExpression(t.thisExpression(), t.identifier(methodName)), [t.stringLiteral(prop)]))])])));
291
291
  }
292
292
  }
293
293
  }
@@ -299,7 +299,7 @@ export default function reactivePlugin() {
299
299
  for (const prop of wProps) {
300
300
  if (reactiveProps.has(prop)) {
301
301
  iife.push(t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('__subs'), t.identifier('push')), [
302
- t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(`__${prop}`)), t.identifier('onChange')), t.identifier('subscribe')), [t.identifier('__cb')])
302
+ t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(`__${prop}`)), t.identifier('onChange')), t.identifier('subscribe')), [t.arrowFunctionExpression([], t.callExpression(t.identifier('__cb'), [t.stringLiteral(prop)]))])
303
303
  ])));
304
304
  }
305
305
  }
@@ -7,8 +7,8 @@ export interface FluffTarget {
7
7
  componentsDir?: string;
8
8
  tsConfigPath?: string;
9
9
  entryPoint?: string;
10
+ exclude?: string[];
10
11
  indexHtml?: string;
11
- components: string[];
12
12
  styles?: string[];
13
13
  assets?: string[];
14
14
  bundle?: BundleOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluffjs/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -8,7 +8,6 @@ export const DEFAULT_CONFIG = {
8
8
  componentsDir: 'app',
9
9
  entryPoint: 'main.ts',
10
10
  indexHtml: 'index.html',
11
- components: ['**/*.component.ts'],
12
11
  assets: ['**/*.html', '**/*.css'],
13
12
  bundle: {
14
13
  minify: true,