Coder Social home page Coder Social logo

mikededo / dartbarrelfilegenerator Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 9.0 7.83 MB

VSCode extension that generates barrel files for Dart projects

License: MIT License

JavaScript 3.47% TypeScript 96.06% Shell 0.47%
barrel-files dart dart-barrel flutter vscode vscode-extension

dartbarrelfilegenerator's Introduction

Hey there, I'm Mike (@mikededo) ๐Ÿ‘‹

I'm a JavaScript/TypeScript developer who loves building stuff with React, whether it's building standalone apps or using meta-frameworks like Next.js. I'm learning other languages such as Go and Rust, to scape a bit of the front-end world, as I'm working as a FE Engineer. I'm a heavy terminal user, always on the lookout for new CLI tools that can simplify my development experience (if you are curious, here are my .dotfiles).

I'm always open to collaboration and newideas. So if you're interested in working together, or just want to chat about programming and life, hit me up!

Aside from that, I'm a cyclist love so most of my spare time is spent on my pedals! :bicyclist:

๐Ÿ‘ Open Source Projects

Dart Barrel File Generator

I once tried developing Flutter apps and I found the necessity of automating the creation of barrel files, since it is something that is really used in the Flutter framework. And, in order to enhance developer experience, I developed ๐Ÿ‘ท the extension for Visual Studio Code.

Readme Card

Squared CI

On my spare time, I'm also working with a tool that simplifies the process of developing GitHub Actions. The idea is to have a no-code like application that ends up generating a workflow file!
The application is still under development, and is nowhere close to be finished! You can try it in: squared-ci.vercel.app

Readme Card

Thanks for stopping by and happy hacking! ๐Ÿš€

dartbarrelfilegenerator's People

Contributors

marcbritton avatar mikededo avatar renovate[bot] avatar scottmacdougall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dartbarrelfilegenerator's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore: replace dependency standard-version with commit-and-tag-version 9.5.0
  • chore: update dependency husky to v9.0.11
  • chore: update dependency @types/vscode to v1.90.0
  • chore: update dependency eslint to v8.57.0
  • chore: update dependency prettier to v3.3.1
  • chore: update dependency typescript to v5.4.5
  • chore: update dependency webpack to v5.91.0
  • chore: update dependency eslint to v9
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • path 0.12.7
  • @types/glob 8.1.0
  • @types/node 20.11.16
  • @types/vscode 1.86.0
  • @typescript-eslint/eslint-plugin 6.20.0
  • @typescript-eslint/parser 6.20.0
  • cz-conventional-changelog 3.3.0
  • eslint 8.56.0
  • husky 9.0.10
  • prettier 3.2.5
  • standard-version 9.5.0
  • ts-loader 9.5.1
  • typescript 5.3.3
  • webpack 5.90.1
  • webpack-cli 5.1.4
  • vscode ^1.86.0

  • Check this box to trigger a request for Renovate to run again on this repository

Setup Husky & commitizen

Husky

Set up Husky pre-commit, in order to run prettier and the linter.

Commitizen

Set up commitizen so that automatic changelog can be created.

yarn

Switch from npm to yarn.

glob patterns not matching as expected

Within the setting excludeDirList, I have added the glob pattern `"**/screens/components/". When I run either the "current folder with nested folders" or the "current with subfolders" commands, I get barrel files that should've been excluded according to the glob pattern.

I verified that the glob pattern is correct using the glob tool.

A work around at the moment is only specify the folder name, such as components. This generates the expected output except this includes all components folders, which is not desired.

I tried **/screens/**/components/**/*.dart within the excludeFileList and got the same result (where the file path doesn't match the glob pattern). Though, **/*.g.dart continues to work as successful glob pattern.

Update command names

I get confused (pretty frequently) which command performs which output. Specifically, Current folder with nested folders and Current with subfolders.

I wonder how this could be re-worded to provide better context?

Current folder with nested folders -> Folders (Recursive)
Current folder only -> This Folder
Current with subfolders -> Folders' Files (Recursive)

I'm open to suggestions!

issue with directory of the same name/architecture

Hi Mike

First of all thank you very much for this great extension, second there seems to be an issue when generating a barrel file for a specific folder with a name that also exist in the test directory.

- lib
   โ”” models
           โ”” model.dart
- test
   โ”” models
           โ”” model_test.dart

The generated file will also export the test directory imports.

can you please fix this issue.

Files with suffix same as folder are not included in barell file

Following structure

modal/
โ”œโ”€ modal_header.dart
โ”œโ”€ single_modal.dart
โ”œโ”€ btn.dart

generated modal.dart contains

export 'btn.dart';
export 'modal_header.dart';

Any file which ends the same as the folder name is not included. Note that the folder's name as a prefix is ok.

Files excluded unexpectedly

We have the following file structure

  • scaffolding
    • large_scaffolding.dart
    • small_scaffolding.dart
    • top_nav_bar.dart
    • bottom_information_bar.dart

When using the plug in the large and small scaffolding files are unexpectedly excluded from the barrel, file, removing the word scaffolding makes them appear, removing it makes them disappear, there's nothing in the documentation that suggests this is expected behaviour

Can't use extension when using multiple folder inside workspace

I can't use the extension when having many folders on my vscode workspace
step to reproduce:

  1. open project folder
  2. add other folder to workspace: file > add folder to workspace
  3. save the workspace as vscode workspace: file > save workspace as
  4. right click on one of the workspaces, generate barrel import
  5. GDBF: Error on generating the file

logger:

[2023-11-14 06:53:19] Type: recursive - Path: c:\Users\my.username\Documents\projects\flutter-project\my_app\lib\modules\my_module
[2023-11-14 06:53:19] ERROR: Error: Select a folder from the workspace
[2023-11-14 06:53:19] Elapsed time: 1ms

how to have a shortcut to barreling command for a hard-coded folder?

having to go to the explorer view, find lib folder, right click and choose the dartBarrelFileGenerator.generateCurrentWithSubfolders command from the context menu I think could be improved, if I could have a shortcut to barreling command for my lib folder. could you advise how to do that please?

Generate single file without generating in its sub folders

If I have a file directory like

lib/test1/example1.dart
lib/test2/example2.dart
lib/test3/example3.dart
lib/test4/example4.dart

Test directories contain only one file. For these, 4 files will be created: test1.dart, test2.dart, test3.dart, test4.dart.

It might be better to merge it into one file instead: lib/<file-name>.dart

Add shortcuts

I tried to add keyboard shortcuts to generate files, but it always throws an error

Option for putting generated file at the same level as target folder

Could it be possible to have the generated file like this?

models\
  course.dart\
  user.dart\
models.dart\ <- The generated file which exports models/course.dart and models/user.dart

This structure can make the import paths look better.

import '../models.dart';
// or this if I only want the course model
import '../models/course.dart'

Btw this extension is really helpful to organise the files, especially in a big project. Nice work!

Renovate bot

Renovate bot

Add the renovate both either via a cron GitHub Action or a GitHub App.

Custom ignore files

Hi, first of all, thanks for your VSCode extension, it helps me a lot.

I looked at configurations in VSCode and I only have found 2 ignore files which you define it: *.freezed.dart and *.g.dart. I believe this ignores is because they use 'part' and 'part of' inside them, and you don't need to export the other file. So I'm using Bloc and now it uses 'part' and 'part of' and I don't use this generates barrel properly because of these files.

I think, instead of create one more option to ignore a file, is it possible to add a list of files/folders to ignore like as git ignore do?

Suggestion with real examples:

You can find this in VSCode>Settings>User>Commonly Used

image

image

Combined option for default file names

Could you add on option to combine the default name and directory name for the barrel file?
For instance, in the the settings directory, I'd like to automatically add settings_index.dart or settings_barrel.dart as the file.
Perhaps in the options, allow something like this: "dartBarrelFileGenerator.defaultBarrelName": "<folder-name>_barrel"

Option for default name of barrel files

Could you maybe add the possibility to change the default name of a barrel file?

I would like to call each barrel file for example index.dart. Currently, a created file overwrites the existing files if they are named exactly like the folder. So index.dart is a good default for us.

Exporting empty files

There is an setting to exclude files and directories from being exported, which is helpful to omit from the export file, but the export file will still be generated even if there are no files to export.

Could we skip the file generation of the empty barrel files?

using excludeFileList to exclude main.dart

i'm trying to ignore main.dart that's in lib folder. when i try to barrel the lib folder, it's not working. what should i put for the value below? thanks

"dartBarrelFileGenerator.excludeFileList": [
"main.dart"
],

`v2.0.0` Iteration plan

This plan captures all the work it should be done before releasing 2.0.0. The goal of this version is to improve the codebase using newer technologies, adding automated testing and CI. This issue will be constantly updated in order to know the progress of the version.

Plan Items

The following list contains the tasks and their priorities for this major version.

Priorities

  • Testing
    • Unit testing
    • Integration testing
    • Set up Github Actions for automated testing
  • TypeScript migration
    • #13
    • Set up Github Actions for automated bundling & compiling

Additional

  • Set up a CI platform
  • Set up automatic changelog, since semmantic commits are now used.
  • Add CONTRIBUTING.md

Not working with extensions

When trying to generate barel from extensions - barel file stays empty

extension Services on List<SelectListItem> {
  String toServicesString() {
    return this.map((e) => e.value).join('    ');
  }
}

works incorrectly if filename and directory name are the same

If I have a file directory like this:

  • index/

    • index.dart
    • test.dart

    If we don't want to enter names. Changing the contents of the index.dart file. This has been a bad experience for me. The contents of many of my files have been changed and converted to export files.

Use generator option on multiple diectories

Would it be possible to select multiple directories and execute the selected generator option on each one individually? It would save a lot of mouseclicks when taking care of lots of separate features in a project.

Sascha

Add option to name the barrel file

By default the extension just uses the name of the parent folder to name the barrel file. Could you add an option to have an optional name for the file?

๏„• lib
โ”œโ”€โ”€ ๏„• commands
โ”‚  โ”œโ”€โ”€ add.dart
โ”‚  โ”œโ”€โ”€ commands.dart
โ”‚  โ”œโ”€โ”€ complete.dart
โ”‚  โ”œโ”€โ”€ remove.dart
โ”‚  โ””โ”€โ”€ show.dart
โ””โ”€โ”€ lib.dart // generated as lib.dart

lib.dart is the generated file, but I would like to name it as todo.dart with the same command: GDBF: Current and Nested Folders

Don't export files with `part of` declarations

Minimal example (using BLoC library):

a_bloc.dart:

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';

part 'a_event.dart';
part 'a_state.dart';

class ABloc extends Bloc<AEvent, AState> {
  ABloc() : super(AInitial()) {
    on<AEvent>((event, emit) {
      // TODO: implement event handler
    });
  }
}

a_event.dart:

part of 'a_bloc.dart';

abstract class AEvent extends Equatable {
  const AEvent();

  @override
  List<Object> get props => [];
}

a_state.dart

part of 'a_bloc.dart';
class AState extends Equatable {
  const AState();
  
  @override
  List<Object> get props => [];
}

Actual output:

export 'a_bloc.dart';
export 'a_event.dart';
export 'a_state.dart';

Expected output:

export 'a_bloc.dart';

Cannot export a nested file with same name as outer folder

Issue:

When using the option 'Current with subfolders' on a directory containing a file with the same name in a subdirectory, the file will not be exported. 'Current folder with nested folders' works as expected

Example:
If you have a feature directory in your project called, i.e.:

car/
   domain/
      car.dart

and you execute 'Current with subfolders' on the car directory, car.dart will not be exported, car/car.dart will be empty

Expected outcome:

car/car.dart should contain: export 'domain/car.dart'

Can't create barrel files on Windows

I'm running vs code on Windows 10 and I'm not being able to create barrel files on my project (a package).

I just get an error message on vs code: GDBF: Error on generating the file.

These are my environment versions:
Version: 1.55.2 (user setup)
Commit: 3c4e3df9e89829dce27b7b5c24508306b151f30d
Date: 2021-04-13T09:35:57.887Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: semanticCommitScopeDisabled

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.