Skip to content

Commit 113e95b

Browse files
committed
chore: upgrade dependencies
1 parent e21f128 commit 113e95b

File tree

9 files changed

+646
-641
lines changed

9 files changed

+646
-641
lines changed

.github/workflows/ci.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,30 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v2
23+
- uses: actions-rs/toolchain@v1
24+
with:
25+
profile: minimal
26+
toolchain: 1.56.0
27+
override: true
28+
- uses: Swatinem/rust-cache@v1
29+
2330
- name: Install wasm32 target
2431
if: matrix.config.kind == 'test_release'
2532
run: rustup target add wasm32-unknown-unknown
2633

27-
- uses: Swatinem/rust-cache@v1
28-
2934
- name: Build debug
3035
if: matrix.config.kind == 'test_debug'
31-
run: cargo build --verbose
36+
run: cargo build
3237
- name: Build release
3338
if: matrix.config.kind == 'test_release'
34-
run: cargo build --target wasm32-unknown-unknown --features wasm --release --verbose
39+
run: cargo build --target wasm32-unknown-unknown --features wasm --release
3540

3641
- name: Test debug
3742
if: matrix.config.kind == 'test_debug'
38-
run: cargo test --verbose
43+
run: cargo test
3944
- name: Test release
4045
if: matrix.config.kind == 'test_release'
41-
run: cargo test --release --verbose
46+
run: cargo test --release
4247

4348
- name: Get tag version
4449
if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "dprint-plugin-dockerfile"
33
version = "0.1.1"
44
authors = ["David Sherret <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66
homepage = "https://github.com/dprint/dprint-plugin-dockerfile"
77
keywords = ["formatting", "formatter", "docker", "dockerfile"]
88
license = "MIT"
@@ -26,7 +26,7 @@ tracing = ["dprint-core/tracing"]
2626

2727
[dependencies]
2828
dockerfile-parser = { git = "https://github.com/dsherret/dockerfile-parser-rs", branch = "span-for-nodes" }
29-
dprint-core = { version = "0.46.4", features = ["formatting"] }
29+
dprint-core = { version = "0.47.0", features = ["formatting"] }
3030
serde = { version = "1.0.88", features = ["derive"] }
3131
serde_json = { version = "1.0", optional = true }
3232

dprint.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
"**/target"
1212
],
1313
"plugins": [
14-
"https://plugins.dprint.dev/typescript-0.55.0.wasm",
15-
"https://plugins.dprint.dev/json-0.13.0.wasm",
16-
"https://plugins.dprint.dev/markdown-0.10.0.wasm",
17-
"https://plugins.dprint.dev/toml-0.5.1.wasm",
14+
"https://plugins.dprint.dev/typescript-0.59.0.wasm",
15+
"https://plugins.dprint.dev/json-0.13.1.wasm",
16+
"https://plugins.dprint.dev/markdown-0.11.1.wasm",
17+
"https://plugins.dprint.dev/toml-0.5.2.wasm",
1818
"https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin@c6bb223ef6e5e87580177f6461a0ab0554ac9ea6b54f78ea7ae8bf63b14f5bc2"
1919
]
2020
}

src/format_text.rs

+37-37
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
use dockerfile_parser::Dockerfile;
2-
use dprint_core::configuration::resolve_new_line_kind;
3-
use dprint_core::formatting::PrintOptions;
4-
use dprint_core::types::ErrBox;
5-
use std::path::Path;
6-
7-
use crate::configuration::Configuration;
8-
use crate::parser::parse_items;
9-
10-
pub fn format_text(_file_path: &Path, text: &str, config: &Configuration) -> Result<String, ErrBox> {
11-
let node = parse_node(text)?;
12-
13-
Ok(dprint_core::formatting::format(
14-
|| parse_items(&node, text, config),
15-
config_to_print_options(text, config),
16-
))
17-
}
18-
19-
#[cfg(feature = "tracing")]
20-
pub fn trace_file(_file_path: &Path, text: &str, config: &Configuration) -> dprint_core::formatting::TracingResult {
21-
let node = parse_node(text).unwrap();
22-
23-
dprint_core::formatting::trace_printing(|| parse_items(node, text, config), config_to_print_options(text, config))
24-
}
25-
26-
fn parse_node(text: &str) -> Result<Dockerfile, ErrBox> {
27-
Ok(Dockerfile::parse(text)?)
28-
}
29-
30-
fn config_to_print_options(text: &str, config: &Configuration) -> PrintOptions {
31-
PrintOptions {
32-
indent_width: 1,
33-
max_width: config.line_width,
34-
use_tabs: false,
35-
new_line_text: resolve_new_line_kind(text, config.new_line_kind),
36-
}
37-
}
1+
use dockerfile_parser::Dockerfile;
2+
use dprint_core::configuration::resolve_new_line_kind;
3+
use dprint_core::formatting::PrintOptions;
4+
use dprint_core::types::ErrBox;
5+
use std::path::Path;
6+
7+
use crate::configuration::Configuration;
8+
use crate::parser::parse_items;
9+
10+
pub fn format_text(_file_path: &Path, text: &str, config: &Configuration) -> Result<String, ErrBox> {
11+
let node = parse_node(text)?;
12+
13+
Ok(dprint_core::formatting::format(
14+
|| parse_items(&node, text, config),
15+
config_to_print_options(text, config),
16+
))
17+
}
18+
19+
#[cfg(feature = "tracing")]
20+
pub fn trace_file(_file_path: &Path, text: &str, config: &Configuration) -> dprint_core::formatting::TracingResult {
21+
let node = parse_node(text).unwrap();
22+
23+
dprint_core::formatting::trace_printing(|| parse_items(node, text, config), config_to_print_options(text, config))
24+
}
25+
26+
fn parse_node(text: &str) -> Result<Dockerfile, ErrBox> {
27+
Ok(Dockerfile::parse(text)?)
28+
}
29+
30+
fn config_to_print_options(text: &str, config: &Configuration) -> PrintOptions {
31+
PrintOptions {
32+
indent_width: 1,
33+
max_width: config.line_width,
34+
use_tabs: false,
35+
new_line_text: resolve_new_line_kind(text, config.new_line_kind),
36+
}
37+
}

src/parser/context.rs

+71-71
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
use std::collections::HashSet;
2-
use std::rc::Rc;
3-
4-
use dockerfile_parser::Dockerfile;
5-
use dockerfile_parser::Span;
6-
7-
use super::helpers::parse_comments;
8-
use super::helpers::Node;
9-
use crate::configuration::Configuration;
10-
11-
pub struct Context<'a> {
12-
pub config: &'a Configuration,
13-
pub dockerfile: &'a Dockerfile,
14-
pub text: &'a str,
15-
pub handled_comments: HashSet<usize>,
16-
current_node: Option<Node<'a>>,
17-
parent_stack: Vec<Node<'a>>,
18-
pub parse_string_content: bool,
19-
}
20-
21-
impl<'a> Context<'a> {
22-
pub fn new(text: &'a str, dockerfile: &'a Dockerfile, config: &'a Configuration) -> Self {
23-
Self {
24-
config,
25-
text,
26-
dockerfile,
27-
handled_comments: HashSet::new(),
28-
current_node: None,
29-
parent_stack: Vec::new(),
30-
parse_string_content: false,
31-
}
32-
}
33-
34-
pub fn span_text(&self, span: &Span) -> &str {
35-
&self.text[span.start..span.end]
36-
}
37-
38-
pub fn set_current_node(&mut self, node: Node<'a>) {
39-
if let Some(parent) = self.current_node.take() {
40-
self.parent_stack.push(parent);
41-
}
42-
self.current_node = Some(node);
43-
}
44-
45-
pub fn pop_current_node(&mut self) {
46-
self.current_node = self.parent_stack.pop();
47-
}
48-
49-
pub fn parent(&self) -> Option<&Node<'a>> {
50-
self.parent_stack.last()
51-
}
52-
53-
pub fn parse_nodes_with_comments(&mut self, start_pos: usize, end_pos: usize, nodes: impl Iterator<Item = Node<'a>>) -> Vec<Node<'a>> {
54-
let mut result = Vec::new();
55-
let mut last_pos = start_pos;
56-
for node in nodes {
57-
let text = &self.text[last_pos..node.span().start];
58-
for comment in parse_comments(text, last_pos) {
59-
result.push(Node::CommentRc(Rc::new(comment)));
60-
}
61-
let node_end = node.span().end;
62-
result.push(node);
63-
last_pos = node_end;
64-
}
65-
let text = &self.text[last_pos..end_pos];
66-
for comment in parse_comments(text, last_pos) {
67-
result.push(Node::CommentRc(Rc::new(comment)));
68-
}
69-
result
70-
}
71-
}
1+
use std::collections::HashSet;
2+
use std::rc::Rc;
3+
4+
use dockerfile_parser::Dockerfile;
5+
use dockerfile_parser::Span;
6+
7+
use super::helpers::parse_comments;
8+
use super::helpers::Node;
9+
use crate::configuration::Configuration;
10+
11+
pub struct Context<'a> {
12+
pub config: &'a Configuration,
13+
pub dockerfile: &'a Dockerfile,
14+
pub text: &'a str,
15+
pub handled_comments: HashSet<usize>,
16+
current_node: Option<Node<'a>>,
17+
parent_stack: Vec<Node<'a>>,
18+
pub parse_string_content: bool,
19+
}
20+
21+
impl<'a> Context<'a> {
22+
pub fn new(text: &'a str, dockerfile: &'a Dockerfile, config: &'a Configuration) -> Self {
23+
Self {
24+
config,
25+
text,
26+
dockerfile,
27+
handled_comments: HashSet::new(),
28+
current_node: None,
29+
parent_stack: Vec::new(),
30+
parse_string_content: false,
31+
}
32+
}
33+
34+
pub fn span_text(&self, span: &Span) -> &str {
35+
&self.text[span.start..span.end]
36+
}
37+
38+
pub fn set_current_node(&mut self, node: Node<'a>) {
39+
if let Some(parent) = self.current_node.take() {
40+
self.parent_stack.push(parent);
41+
}
42+
self.current_node = Some(node);
43+
}
44+
45+
pub fn pop_current_node(&mut self) {
46+
self.current_node = self.parent_stack.pop();
47+
}
48+
49+
pub fn parent(&self) -> Option<&Node<'a>> {
50+
self.parent_stack.last()
51+
}
52+
53+
pub fn parse_nodes_with_comments(&mut self, start_pos: usize, end_pos: usize, nodes: impl Iterator<Item = Node<'a>>) -> Vec<Node<'a>> {
54+
let mut result = Vec::new();
55+
let mut last_pos = start_pos;
56+
for node in nodes {
57+
let text = &self.text[last_pos..node.span().start];
58+
for comment in parse_comments(text, last_pos) {
59+
result.push(Node::CommentRc(Rc::new(comment)));
60+
}
61+
let node_end = node.span().end;
62+
result.push(node);
63+
last_pos = node_end;
64+
}
65+
let text = &self.text[last_pos..end_pos];
66+
for comment in parse_comments(text, last_pos) {
67+
result.push(Node::CommentRc(Rc::new(comment)));
68+
}
69+
result
70+
}
71+
}

0 commit comments

Comments
 (0)