diff --git a/bake/bakefile.py b/bake/bakefile.py index eecab83..bd92fa4 100644 --- a/bake/bakefile.py +++ b/bake/bakefile.py @@ -206,12 +206,26 @@ class TaskScript(BaseAction): actions = [t for t in gen_actions()] if recursive: + graph = {} actions = [] - _last_action = None - for _, action in list(networkx.dfs_edges(self.bashfile.graph, self)): - if _last_action != action: - actions.append(action) - _last_action = action + + edge_view = networkx.edge_dfs( + self.bashfile.graph, self, orientation="original" + ) + + for parent, child, _ in edge_view: + if parent not in graph: + graph[parent] = [child] + else: + graph[parent].append(child) + + for task in graph: + for action in graph[task]: + for dep_action in graph.get(action, []): + if dep_action not in actions: + actions.append(dep_action) + if action not in actions: + actions.append(action) return actions @@ -357,13 +371,9 @@ class Bakefile: g = networkx.OrderedDiGraph() for task in self.tasks.values(): - if task not in g: - g.add_node(task) - + g.add_node(task) for dep in task.depends_on(): - if dep not in g: - g.add_node(dep) - + g.add_node(dep) g.add_edge(task, dep) self._graph = g diff --git a/bake/cli.py b/bake/cli.py index b5acdcc..00b7778 100644 --- a/bake/cli.py +++ b/bake/cli.py @@ -269,11 +269,12 @@ def entrypoint( depends_on = () if depends_on: - deps = [] - for dep in depends_on: - if dep.is_filter: - dep = click.style(str(dep), fg="yellow") - deps.append(str(dep)) + # deps = [] + # for dep in depends_on: + # if dep.is_filter: + # dep = click.style(str(dep), fg="yellow") + # deps.append(str(dep)) + deps = [str(a) for a in depends_on] deps = f"\n {click.style('+', fg='yellow', bold=True)} {eng_join(deps, conj='&')}." else: deps = "" diff --git a/contrib/bake-vscode/Bakefile b/contrib/bake-vscode/Bakefile index d2d02d7..a3b684a 100644 --- a/contrib/bake-vscode/Bakefile +++ b/contrib/bake-vscode/Bakefile @@ -12,4 +12,3 @@ ms/package: install/system install/system: npm install -g yo generator-code vsce -vnfpzyctwdml75il7y5prfe3637lbvr4wpkje3mtecgbqbm3fhmq diff --git a/contrib/bake-vscode/README.md b/contrib/bake-vscode/README.md index 6731b1c..010e20c 100644 --- a/contrib/bake-vscode/README.md +++ b/contrib/bake-vscode/README.md @@ -33,6 +33,11 @@ This project seeks to bridge all of these worlds into a single entrypoint — i - Tasks can be run safely and reliably. Rest assured that scripts are executed from the project root (e.g. location of the `Bakefile`). - See [advanced example](https://github.com/kennethreitz/bake#advanced-usage-sample) for further, juicy, details. + +### Community / Contrib + +- [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=kennethreitz.bake) — highlights `Bakefile`. + ------------------ ## Installing `$ bake` diff --git a/contrib/bake-vscode/bake-0.0.1.vsix b/contrib/bake-vscode/bake-0.0.1.vsix deleted file mode 100644 index 88a312e..0000000 Binary files a/contrib/bake-vscode/bake-0.0.1.vsix and /dev/null differ diff --git a/contrib/bake-vscode/package.json b/contrib/bake-vscode/package.json index de7e332..38bad1f 100644 --- a/contrib/bake-vscode/package.json +++ b/contrib/bake-vscode/package.json @@ -1,43 +1,48 @@ { - "name": "bake", - "displayName": "bake", - "description": "Hilighting for Bake: a strangely familiar task runner.", - "version": "0.0.1", - "publisher": "kennethreitz", - "repository": "https://github.com/kennethreitz/bake.git", - "engines": { - "vscode": "^1.38.0" - }, - "categories": [ - "Programming Languages" - ], - "contributes": { - "languages": [ - { - "id": "bakefile", - "aliases": [ - "Bakefile", - "bakefile" - ], - "extensions": [ - "Bakefile" - ], - "configuration": "./language-configuration.json" - } - ], - "grammars": [ - { - "language": "bakefile", - "scopeName": "source.bakefile", - "path": "./syntaxes/Bakefile.syntax.json", - "embeddedLanguages": { - "task": "source.shell" - } - } - ] - }, - "dependencies": { - "generator-code": "^1.2.6", - "vsce": "^1.66.0" - } -} + "name": "bake", + "displayName": "bake", + "description": "Hilighting for Bake: a strangely familiar task runner.", + "version": "0.0.1", + "publisher": "kennethreitz", + "repository": "https://github.com/kennethreitz/bake.git", + "engines": { + "vscode": "^1.38.0" + }, + "categories": [ + "Programming Languages" + ], + "contributes": { + "languages": [ + { + "id": "bakefile", + "aliases": [ + "Bakefile", + "bakefile" + ], + "extensions": [ + "Bakefile" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "bakefile", + "scopeName": "source.bakefile", + "path": "./syntaxes/Bakefile.syntax.json", + "embeddedLanguages": { + "task": "source.shell" + } + } + ] + }, + "dependencies": { + "generator-code": "^1.2.6", + "vsce": "^1.66.0" + }, + "__metadata": { + "id": "9c773cc4-328c-4e24-84c9-3cc5ba85b3d0", + "publisherDisplayName": "kennethreitz", + "publisherId": "7bf106b0-2ddb-49af-9b16-bbd0067cf5a9" + } +} \ No newline at end of file diff --git a/setup.py b/setup.py index 7457f96..df94db4 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ URL = "https://github.com/kennethreitz/bake" EMAIL = "me@kennethreitz.org" AUTHOR = "Kenneth Reitz" REQUIRES_PYTHON = ">=3.6.0" -VERSION = "0.4.1" +VERSION = "0.5.0" # What packages are required for this module to be executed? REQUIRED = ["click", "delegator.py", "pygments", "networkx"]