Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

support two types of extra config #1

Closed
kamilsk opened this issue May 24, 2016 · 31 comments
Closed

support two types of extra config #1

kamilsk opened this issue May 24, 2016 · 31 comments
Assignees
Milestone

Comments

@kamilsk
Copy link
Member

kamilsk commented May 24, 2016

case 1.

  dev-files:
  - "/dev-for-clear/*"
  - "!dev-for-clear/subdir/miss.md"

case 2.

  dev-files:
    docs: ["/CHANGELOG.md"]
    tests: ["/Tests", "/phpunit.xml.dist"]
    bin: ["/bin"]
    others: [".git*"]
@kamilsk kamilsk added this to the 1.0 milestone May 24, 2016
@kamilsk kamilsk self-assigned this May 24, 2016
@mlocati
Copy link

mlocati commented May 24, 2016

Or maybe simply

dev-files:
  - "/dev-for-clear/*"
  - "!dev-for-clear/subdir/miss.md"
dev-files-bin:
  - "/bin"

@kamilsk
Copy link
Member Author

kamilsk commented May 24, 2016

@mlocati, for the second case I don't imagine how composer remove only docs for package1 and only bin for package2. any suggestion?

@mlocati
Copy link

mlocati commented May 24, 2016

It's just to have a simpler process: instead of having many categories, we could have just two ("remove always", and "always remove + remove bin"): docs, tests, ... could be always removed, bin only if requested.
These two solutions are alternatives, not meant to be both valid... I'm just adding some arguments before coding starts.

@kamilsk
Copy link
Member Author

kamilsk commented May 24, 2016

How about this API:

package 1:

{
  "extra": {
    "dev-files": [
      "/Tests", "/docs"
    ],
  }
}

package 2:

{
  "extra": {
    "dev-files": {
        "docs": ["/docs/Some.md"],
        "bin": ["/bin", "/actions/test.sh"]
    },
  }
}

project:

{
  "require": {
    "package 1": "*",
    "package 2": "*"
  },
  "config": {
    "octolab/cleaner": {
      "clean": { "package 1": ["docs"], "package 2": ["bin"] }
    }
  }
}

composer install will remove only bin in package 2, because docs not presented in package 1

if I change config to this: "clean": "*", than composer install remove all dev-files.

@mlocati
Copy link

mlocati commented May 24, 2016

What about this?

{
    "require": {
        "package 1": "*",
        "package 2": "*",
        "package 3": "*"
    },
    "config": {
        "octolab/cleaner": {
            "clean": {
                "*": ["docs"],
                "package 2": ["bin"],
                "package 3": "*"
            }
        }
    }
}

The "*" key for the package name could mean "all packages except the ones explicitly listed".
The "*" values mean "everything"

EDIT: I updated the above sample json

@mlocati
Copy link

mlocati commented May 24, 2016

Another improvement option could be a syntax like

{
            "clean": {
                "*": "!bin"
            }
}

meaning "all except bin", but things start being quite complex 😉

@kamilsk
Copy link
Member Author

kamilsk commented May 24, 2016

yep, #1 (comment) looks interesting. if octolab/cleaner config is not presented, than it do nothing.

@kamilsk
Copy link
Member Author

kamilsk commented May 24, 2016

#1 (comment) increase complexity and I would like to implement "excluding" outside the MVP (maybe in feature release)

@mlocati
Copy link

mlocati commented May 24, 2016

#1 (comment) increase complexity and I would like to implement "excluding" outside the MVP (maybe in feature release)

Yes, I'm totally with you.
By the way, we'd need to define a list of all the possible "categories", so that developers can say "delete all except bin" by listing the other categories.
For instance, we can impose that the categories could be only "bin", "doc", "example", "test", "other", and telling "all except bin" could be done by listing "doc example test other"

@mlocati
Copy link

mlocati commented May 24, 2016

And in case of your "case 1." above, the files could be assumed as "other".

@kamilsk
Copy link
Member Author

kamilsk commented May 24, 2016

OK, I will freeze API tomorrow morning and write specs on wiki. With the specs I continue my work above the plugin.

All features that will not be presented on it will moved to future releases.

@kamilsk
Copy link
Member Author

kamilsk commented May 24, 2016

#1 (comment) you mean that default category name is "other" ?

@mlocati
Copy link

mlocati commented May 24, 2016

#1 (comment) you mean that default category name is "other" ?

I don't see a better alternative...

@kamilsk
Copy link
Member Author

kamilsk commented May 24, 2016

I was just trying to think of a name for this category :) "other" is good to me

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

@mlocati done https://github.com/octolab/Cleaner/wiki, can you review?

@mlocati
Copy link

mlocati commented May 25, 2016

Just two notes:

Categories

Let's assume I want to delete all the unnecessary files but the bin ones: in this case I need to know which may be all the other categories.
So, I'd impose that we can have only a fixed set of categories (bin, docs, tests, other): if one tries to use another category, I'd raise an error.

Path specification

It would be great if path specs will be compatible with the ones used by git.
For instance:

  • *.c matches all the files with a .c extension, in any directory
  • /test/*.c matches all the files with a .c extension that are in the /test directory (but not in /test/subfolder/)
  • /test/**/*.c matches all the files with a .c extension that are in the /test directory and in all its subdirectories

And also

  • path matches any file or directory whose name is path
  • path/ matches only directories

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

about path specification: all works based on http://symfony.com/doc/current/components/finder.html, create another component not at the moment, but I try to do it extendable.

git pattern format is really true way, it is transparent to .gitattributes, and maybe it fully supported by finder, but at the start I would like to get feedback about how this decision will be demanded, and whether the work done by the effort

about categories: introduce the dictionary is not a flexible way, I freeze only one word other. I don't want to get issues like this ones

Could you add category buzzword?

@mlocati
Copy link

mlocati commented May 25, 2016

about categories: introduce the dictionary is not a flexible way, I freeze only one word other. I don't want to get issues like this ones

Could you add category buzzword?

So, how would you say "delete all the categories except bin"?

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

https://github.com/octolab/Cleaner/wiki was updated

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

@mlocati
Copy link

mlocati commented May 25, 2016

Weight of operators:

Consider the case when we have 100 packages, and we want to keep the bin files of just one package.
This could be easily specified if we interpret this code

config:
  octolab/cleaner:
    clean:
      *: *
      vendor/package1: !bin

as

by default remove all dev-files, but for vendor/package1 keep only bin

What I mean is that the * package could be assumed to be the default behavior: if a package is not explicitly described we use this default behavior.

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

good point, changed for this

1. `package:  *`
2. `package: [!]`
3. `package: [ ]`
4. `*: *`
5. `*: [!]`
6. `*: [ ]`

What do you think?

@mlocati
Copy link

mlocati commented May 25, 2016

What about

1. `package: [!]`
2. `package: [ ]`
3. `package:  *`
4. `*: [!]`
5. `*: [ ]`
6. `*: *`

I mean, the asterisk has always the lowest priority even when specifying the categories to delete:
by reading this:

config:
  octolab/cleaner:
    clean:
      vendor/package1: [*, !docs]

IMHO it's more natural to read it delete all, but not docs (furthermore it's much saver, if someone writes an asterisk by mistake he/she delete everything).

PS: what's the ~ here?

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

PS: what's the ~ here?

in YAML is null after parsing

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

[*, !docs, info] === [!docs, info] === [!docs] -> remove all except docs?

@kamilsk
Copy link
Member Author

kamilsk commented May 25, 2016

wiki was updated, so, if you don't have any other suggestions I lock this conversation

@mlocati
Copy link

mlocati commented May 25, 2016

wiki was updated, so, if you don't have any other suggestions I lock this conversation

👍

@mlocati
Copy link

mlocati commented May 25, 2016

[*, !docs, info] === [!docs, info] === [!docs] -> remove all except docs?

👍

@mlocati
Copy link

mlocati commented May 25, 2016

I using examples on YAML because I really like this format:

Yes, it's cleaner and a bit shorter than json.
BTW I've worked with XML a lot, so for me JSON is short and clean enough :D

@octolab octolab locked and limited conversation to collaborators May 25, 2016
@kamilsk
Copy link
Member Author

kamilsk commented May 31, 2016

fixed

@kamilsk kamilsk closed this as completed May 31, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants