platformos-check 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +22 -7
- data/data/platformos_liquid/documentation/latest.json +1 -1
- data/docker/bin/platformos-check +13 -0
- data/docker/bin/platformos-check-language-server +13 -0
- data/docker/check.Dockerfile +1 -1
- data/docker/lsp.Dockerfile +1 -1
- data/lib/platformos_check/app.rb +11 -13
- data/lib/platformos_check/app_file.rb +6 -2
- data/lib/platformos_check/asset_file.rb +8 -2
- data/lib/platformos_check/checks/undefined_object.rb +16 -0
- data/lib/platformos_check/form_file.rb +15 -0
- data/lib/platformos_check/language_server/constants.rb +15 -1
- data/lib/platformos_check/language_server/document_link_engine.rb +3 -1
- data/lib/platformos_check/language_server/document_link_provider.rb +28 -11
- data/lib/platformos_check/language_server/document_link_providers/asset_document_link_provider.rb +2 -2
- data/lib/platformos_check/language_server/document_link_providers/background_document_link_provider.rb +12 -0
- data/lib/platformos_check/language_server/document_link_providers/function_document_link_provider.rb +12 -0
- data/lib/platformos_check/language_server/document_link_providers/graphql_document_link_provider.rb +12 -0
- data/lib/platformos_check/language_server/document_link_providers/include_document_link_provider.rb +3 -2
- data/lib/platformos_check/language_server/document_link_providers/include_form_document_link_provider.rb +12 -0
- data/lib/platformos_check/language_server/document_link_providers/render_document_link_provider.rb +3 -2
- data/lib/platformos_check/language_server/hover_providers/filter_hover_provider.rb +3 -4
- data/lib/platformos_check/liquid_file.rb +4 -12
- data/lib/platformos_check/tags/background.rb +3 -1
- data/lib/platformos_check/version.rb +1 -1
- data/lib/platformos_check.rb +1 -0
- data/platformos-check.gemspec +2 -0
- metadata +23 -3
- data/lib/platformos_check/language_server/document_link_providers/section_document_link_provider.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ba7e3e116a304539c0acc6f347bf90c1aad32190c62a5bf93c21d2ba71a107c
|
4
|
+
data.tar.gz: ac02ba8e692d4143480f28a261f81bc0b3eae49be54e435b28cb3c420463e5c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0957f4004a15c3d3451d6008d2d28be6c9bfa8f3d3b0f53dd6d08d64987d40e1534024ebfc5da3b493b3fa5c777b7766ba41323463b8ae6bc938a2971b695017'
|
7
|
+
data.tar.gz: 60b62e31457173e1b4a9048b4d3c13ad385d7483c711a8b55998b618a1f4ec5eb67342eee202838b0f4887949e925106ad4ed537b5cd3f5c65125e8beb7ff808
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
v0.0.3 / 2023-09-11
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Fix GraphQL dependency issue
|
5
|
+
* Support background tag in UndefinedObject check
|
6
|
+
|
7
|
+
v0.0.2 / 2023-09-09
|
8
|
+
==================
|
9
|
+
|
10
|
+
* Add documentLink support for pOS tags for easy navigation, aka ctrl + click to quickly access file invoked by render, include, graphql, background and include_form tags
|
11
|
+
* Treat Form as liquid file and check it
|
1
12
|
|
2
13
|
v0.0.1 / 2023-08-19
|
3
14
|
==================
|
data/CONTRIBUTING.md
CHANGED
@@ -56,7 +56,7 @@ Before configuring your IDE, run the following commands in a terminal:
|
|
56
56
|
```
|
57
57
|
"platformosCheck.checkOnChange": true,
|
58
58
|
"platformosCheck.onlySingleFileChecks": false,
|
59
|
-
"
|
59
|
+
"platformosLiquid.languageServerPath": "/Users/<your user>/bin/platformos-check-language-server",
|
60
60
|
"platformosCheck.checkOnOpen": true,
|
61
61
|
"platformosCheck.checkOnSave": true
|
62
62
|
```
|
data/README.md
CHANGED
@@ -10,9 +10,9 @@ PlatformOS Check currently checks for the following:
|
|
10
10
|
|
11
11
|
✅ Liquid syntax errors
|
12
12
|
✅ JSON syntax errors
|
13
|
-
✅ Missing
|
13
|
+
✅ Missing partials and graphqls
|
14
14
|
✅ Unused `{% assign ... %}`
|
15
|
-
✅ Unused
|
15
|
+
✅ Unused partials
|
16
16
|
✅ Template length
|
17
17
|
✅ Deprecated tags
|
18
18
|
✅ Unknown tags
|
@@ -22,6 +22,7 @@ PlatformOS Check currently checks for the following:
|
|
22
22
|
✅ Undefined objects
|
23
23
|
✅ Deprecated filters
|
24
24
|
✅ Missing `platformos-check-enable` comment
|
25
|
+
✅ Invalid arguments provided to `{% graphql %}` tags
|
25
26
|
|
26
27
|
As well as checks that prevent easy to spot performance problems:
|
27
28
|
|
@@ -48,7 +49,15 @@ With more to come! Suggestions welcome ([create an issue](https://github.com/Pla
|
|
48
49
|
|
49
50
|
- Ruby 3.2+
|
50
51
|
|
51
|
-
|
52
|
+
### Install ruby and platform-check gem
|
53
|
+
|
54
|
+
1. Download the latest version of Ruby - https://www.ruby-lang.org/en/documentation/installation/
|
55
|
+
2. Install platformos-check gem
|
56
|
+
|
57
|
+
`gem install platformos-check`
|
58
|
+
|
59
|
+
You can verify the installation was successful by invoking `platformos-check --version`. If you chose this method, use `platformos-check-language-server` as a path to your language server instead of `/Users/<username/platformos-check-language-server`
|
60
|
+
|
52
61
|
|
53
62
|
### Using Docker
|
54
63
|
|
@@ -61,7 +70,7 @@ DIR=$(pwd)
|
|
61
70
|
IMAGE_NAME=platformos/platformos-lsp:latest
|
62
71
|
|
63
72
|
LOG_DIR=$DIR/logs
|
64
|
-
mkdir $LOG_DIR
|
73
|
+
mkdir $LOG_DIR 2>/dev/null
|
65
74
|
LOG_FILE=$LOG_DIR/platformos-lsp.log
|
66
75
|
|
67
76
|
exec docker run -i \
|
@@ -69,7 +78,7 @@ exec docker run -i \
|
|
69
78
|
-w $DIR \
|
70
79
|
-e PLATFORMOS_CHECK_DEBUG=true \
|
71
80
|
-e PLATFORMOS_CHECK_DEBUG_LOG_FILE=$LOG_FILE \
|
72
|
-
$IMAGE_NAME
|
81
|
+
$IMAGE_NAME $@
|
73
82
|
```
|
74
83
|
This script will automatically download the latest Docker image and initiate a language server. Visual Studio Code (VSC) manages this process automatically. However, you can run the script for verification if needed."
|
75
84
|
|
@@ -86,7 +95,7 @@ DIR=$(pwd)
|
|
86
95
|
IMAGE_NAME=platformos/platformos-check:latest
|
87
96
|
|
88
97
|
LOG_DIR=$DIR/logs
|
89
|
-
mkdir $LOG_DIR
|
98
|
+
mkdir $LOG_DIR 2>/dev/null
|
90
99
|
LOG_FILE=$LOG_DIR/platformos-check.log
|
91
100
|
|
92
101
|
exec docker run -i \
|
@@ -94,7 +103,13 @@ exec docker run -i \
|
|
94
103
|
-w $DIR \
|
95
104
|
-e PLATFORMOS_CHECK_DEBUG=true \
|
96
105
|
-e PLATFORMOS_CHECK_DEBUG_LOG_FILE=$LOG_FILE \
|
97
|
-
$IMAGE_NAME
|
106
|
+
$IMAGE_NAME $@
|
107
|
+
```
|
108
|
+
To verify installation run `platformos-check --help`.
|
109
|
+
|
110
|
+
Usage example for CI/CD:
|
111
|
+
```
|
112
|
+
platformos-check --fail-level error
|
98
113
|
```
|
99
114
|
|
100
115
|
## Configuration
|
@@ -1,2 +1,2 @@
|
|
1
1
|
|
2
|
-
{"revision":"
|
2
|
+
{"revision":"e1c423c3470100b88c95fcf84af15c652f2c89b7"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
DIR=$(pwd)
|
2
|
+
IMAGE_NAME=platformos/platformos-check:latest
|
3
|
+
|
4
|
+
LOG_DIR=$DIR/logs
|
5
|
+
mkdir $LOG_DIR 2>/dev/null
|
6
|
+
LOG_FILE=$LOG_DIR/platformos-check.log
|
7
|
+
|
8
|
+
docker run -i \
|
9
|
+
-v $DIR:$DIR \
|
10
|
+
-w $DIR \
|
11
|
+
-e PLATFORMOS_CHECK_DEBUG=true \
|
12
|
+
-e PLATFORMOS_CHECK_DEBUG_LOG_FILE=$LOG_FILE \
|
13
|
+
$IMAGE_NAME $@
|
@@ -0,0 +1,13 @@
|
|
1
|
+
DIR=$(pwd)
|
2
|
+
IMAGE_NAME=platformos/platformos-lsp:latest
|
3
|
+
|
4
|
+
LOG_DIR=$DIR/logs
|
5
|
+
mkdir $LOG_DIR 2>/dev/null
|
6
|
+
LOG_FILE=$LOG_DIR/platformos-lsp.log
|
7
|
+
|
8
|
+
exec docker run -i \
|
9
|
+
-v $DIR:$DIR \
|
10
|
+
-w $DIR \
|
11
|
+
-e PLATFORMOS_CHECK_DEBUG=true \
|
12
|
+
-e PLATFORMOS_CHECK_DEBUG_LOG_FILE=$LOG_FILE \
|
13
|
+
$IMAGE_NAME
|
data/docker/check.Dockerfile
CHANGED
data/docker/lsp.Dockerfile
CHANGED
@@ -16,6 +16,6 @@ RUN git clone https://github.com/Platform-OS/platformos-lsp.git && \
|
|
16
16
|
|
17
17
|
RUN adduser --disabled-password --gecos '' platformos && chown platformos:platformos -R /app
|
18
18
|
|
19
|
-
ENTRYPOINT "
|
19
|
+
ENTRYPOINT ["/app/platformos-lsp/exe/platformos-check-language-server"]
|
20
20
|
|
21
21
|
USER platformos
|
data/lib/platformos_check/app.rb
CHANGED
@@ -14,6 +14,7 @@ module PlatformosCheck
|
|
14
14
|
MIGRATIONS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)migrations/(.+)\.liquid\z}
|
15
15
|
PAGES_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(pages|views/pages)/(.+)}
|
16
16
|
PARTIALS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(views/partials|lib)/(.+)}
|
17
|
+
FORMS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(form_configurations|forms)/(.+)\.liquid\z}
|
17
18
|
LAYOUTS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(views/layouts)/(.+)}
|
18
19
|
SCHEMA_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(custom_model_types|model_schemas|schema)/(.+)\.yml\z}
|
19
20
|
SMSES_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/sms_notifications|smses)/(.+)\.liquid\z}
|
@@ -29,6 +30,7 @@ module PlatformosCheck
|
|
29
30
|
MIGRATIONS_REGEX => MigrationFile,
|
30
31
|
PAGES_REGEX => PageFile,
|
31
32
|
PARTIALS_REGEX => PartialFile,
|
33
|
+
FORMS_REGEX => FormFile,
|
32
34
|
LAYOUTS_REGEX => LayoutFile,
|
33
35
|
SCHEMA_REGEX => SchemaFile,
|
34
36
|
SMSES_REGEX => SmsFile,
|
@@ -67,7 +69,7 @@ module PlatformosCheck
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def liquid
|
70
|
-
layouts + partials + pages + notifications
|
72
|
+
layouts + partials + forms + pages + notifications
|
71
73
|
end
|
72
74
|
|
73
75
|
def yaml
|
@@ -86,6 +88,10 @@ module PlatformosCheck
|
|
86
88
|
grouped_files[PartialFile]&.values || []
|
87
89
|
end
|
88
90
|
|
91
|
+
def forms
|
92
|
+
grouped_files[FormFile]&.values || []
|
93
|
+
end
|
94
|
+
|
89
95
|
def layouts
|
90
96
|
grouped_files[LayoutFile]&.values || []
|
91
97
|
end
|
@@ -98,6 +104,10 @@ module PlatformosCheck
|
|
98
104
|
grouped_files[EmailFile]&.values || []
|
99
105
|
end
|
100
106
|
|
107
|
+
def graphqls
|
108
|
+
grouped_files[GraphqlFile]&.values || []
|
109
|
+
end
|
110
|
+
|
101
111
|
def smses
|
102
112
|
grouped_files[SmsFile]&.values || []
|
103
113
|
end
|
@@ -110,10 +120,6 @@ module PlatformosCheck
|
|
110
120
|
grouped_files[PageFile]&.values || []
|
111
121
|
end
|
112
122
|
|
113
|
-
def directories
|
114
|
-
storage.directories
|
115
|
-
end
|
116
|
-
|
117
123
|
def all
|
118
124
|
@all ||= grouped_files.values.map(&:values).flatten
|
119
125
|
end
|
@@ -126,13 +132,5 @@ module PlatformosCheck
|
|
126
132
|
all.find { |t| t.name == name_or_relative_path }
|
127
133
|
end
|
128
134
|
end
|
129
|
-
|
130
|
-
def sections
|
131
|
-
liquid.select(&:section?)
|
132
|
-
end
|
133
|
-
|
134
|
-
def snippets
|
135
|
-
liquid.select(&:snippet?)
|
136
|
-
end
|
137
135
|
end
|
138
136
|
end
|
@@ -23,11 +23,15 @@ module PlatformosCheck
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def name
|
26
|
-
@name ||= dir_prefix.nil? ? relative_path
|
26
|
+
@name ||= dir_prefix.nil? ? remove_extension(relative_path).to_s : build_name
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_extension(path)
|
30
|
+
path.sub_ext('')
|
27
31
|
end
|
28
32
|
|
29
33
|
def build_name
|
30
|
-
n = relative_path.sub(dir_prefix, '')
|
34
|
+
n = remove_extension(relative_path.sub(dir_prefix, '')).to_s
|
31
35
|
return n if module_name.nil?
|
32
36
|
|
33
37
|
prefix = "modules#{File::SEPARATOR}#{module_name}#{File::SEPARATOR}"
|
@@ -4,6 +4,8 @@ require "zlib"
|
|
4
4
|
|
5
5
|
module PlatformosCheck
|
6
6
|
class AssetFile < AppFile
|
7
|
+
DIR_PREFIX = %r{\A/?((marketplace_builder|app)/assets/|modules/((\w|-)*)/(private|public)/assets/)}
|
8
|
+
|
7
9
|
def initialize(relative_path, storage)
|
8
10
|
super
|
9
11
|
@loaded = false
|
@@ -27,8 +29,12 @@ module PlatformosCheck
|
|
27
29
|
@gzipped_size ||= Zlib.gzip(source).bytesize
|
28
30
|
end
|
29
31
|
|
30
|
-
def
|
31
|
-
|
32
|
+
def dir_prefix
|
33
|
+
DIR_PREFIX
|
34
|
+
end
|
35
|
+
|
36
|
+
def remove_extension(path)
|
37
|
+
path
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
@@ -127,6 +127,19 @@ module PlatformosCheck
|
|
127
127
|
@files[node.app_file.name].all_assigns[node.value.to] = node
|
128
128
|
end
|
129
129
|
|
130
|
+
def on_background(node)
|
131
|
+
return if ignore?(node)
|
132
|
+
return unless node.value.partial_syntax
|
133
|
+
return unless node.value.partial_name.is_a?(String)
|
134
|
+
|
135
|
+
@files[node.app_file.name].add_render(
|
136
|
+
name: node.value.partial_name,
|
137
|
+
node:
|
138
|
+
)
|
139
|
+
|
140
|
+
@files[node.app_file.name].all_assigns[node.value.to] = node
|
141
|
+
end
|
142
|
+
|
130
143
|
def on_variable_lookup(node)
|
131
144
|
return if ignore?(node)
|
132
145
|
|
@@ -144,6 +157,9 @@ module PlatformosCheck
|
|
144
157
|
if info.app_file.notification?
|
145
158
|
# NOTE: `data` comes from graphql for notifications
|
146
159
|
check_object(info, all_global_objects + %w[data response form])
|
160
|
+
elsif info.app_file.form?
|
161
|
+
# NOTE: `data` comes from graphql for notifications
|
162
|
+
check_object(info, all_global_objects + %w[form form_builder])
|
147
163
|
else
|
148
164
|
check_object(info, all_global_objects)
|
149
165
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
class FormFile < LiquidFile
|
5
|
+
DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(form_configurations|forms)/|modules/((\w|-)*)/(private|public)/(form_configurations|forms)/)}
|
6
|
+
|
7
|
+
def form?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
def dir_prefix
|
12
|
+
DIR_PREFIX
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -13,9 +13,23 @@ module PlatformosCheck
|
|
13
13
|
/mix
|
14
14
|
end
|
15
15
|
|
16
|
+
def self.partial_tag_with_result(tag)
|
17
|
+
/
|
18
|
+
\{%-?\s*#{tag}\s+(?<var>[\w]+)+\s*=\s*'(?<partial>[^']*)'|
|
19
|
+
\{%-?\s*#{tag}\s+(?<var>[\w]+)\s*=\s*"(?<partial>[^"]*)"|
|
20
|
+
|
21
|
+
# in liquid tags the whole line is white space until the tag
|
22
|
+
^\s*#{tag}\s+(?<var>[\w]+)+\s*=\s*'(?<partial>[^']*)'|
|
23
|
+
^\s*#{tag}\s+(?<var>[\w]+)+\s*=\s*"(?<partial>[^"]*)"
|
24
|
+
/mix
|
25
|
+
end
|
26
|
+
|
16
27
|
PARTIAL_RENDER = partial_tag('render')
|
17
28
|
PARTIAL_INCLUDE = partial_tag('include')
|
18
|
-
|
29
|
+
PARTIAL_INCLUDE_FORM = partial_tag('include_form')
|
30
|
+
PARTIAL_FUNCTION = partial_tag_with_result('function')
|
31
|
+
PARTIAL_GRAPHQL = partial_tag_with_result('graphql')
|
32
|
+
PARTIAL_BACKGROUND = partial_tag_with_result('background')
|
19
33
|
|
20
34
|
ASSET_INCLUDE = /
|
21
35
|
\{\{-?\s*'(?<partial>[^']*)'\s*\|\s*asset_url|
|
@@ -12,8 +12,10 @@ module PlatformosCheck
|
|
12
12
|
buffer = @storage.read(relative_path)
|
13
13
|
return [] unless buffer
|
14
14
|
|
15
|
+
platformos_app = PlatformosCheck::App.new(@storage)
|
16
|
+
|
15
17
|
@providers.flat_map do |p|
|
16
|
-
p.document_links(buffer)
|
18
|
+
p.document_links(buffer, platformos_app)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -8,7 +8,7 @@ module PlatformosCheck
|
|
8
8
|
include URIHelper
|
9
9
|
|
10
10
|
class << self
|
11
|
-
attr_accessor :partial_regexp, :
|
11
|
+
attr_accessor :partial_regexp, :app_file_type, :default_dir, :default_extension
|
12
12
|
|
13
13
|
def all
|
14
14
|
@all ||= []
|
@@ -23,19 +23,23 @@ module PlatformosCheck
|
|
23
23
|
@storage = storage
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
self.class.
|
26
|
+
def app_file_type
|
27
|
+
self.class.app_file_type
|
28
|
+
end
|
29
|
+
|
30
|
+
def default_dir
|
31
|
+
self.class.default_dir
|
28
32
|
end
|
29
33
|
|
30
|
-
def
|
31
|
-
self.class.
|
34
|
+
def default_extension
|
35
|
+
self.class.default_extension
|
32
36
|
end
|
33
37
|
|
34
|
-
def
|
35
|
-
self.class.
|
38
|
+
def partial_regexp
|
39
|
+
self.class.partial_regexp
|
36
40
|
end
|
37
41
|
|
38
|
-
def document_links(buffer)
|
42
|
+
def document_links(buffer, platformos_app)
|
39
43
|
matches(buffer, partial_regexp).map do |match|
|
40
44
|
start_row, start_column = from_index_to_row_column(
|
41
45
|
buffer,
|
@@ -48,7 +52,7 @@ module PlatformosCheck
|
|
48
52
|
)
|
49
53
|
|
50
54
|
{
|
51
|
-
target: file_link(match[:partial]),
|
55
|
+
target: file_link(match[:partial], platformos_app),
|
52
56
|
range: {
|
53
57
|
start: {
|
54
58
|
line: start_row,
|
@@ -63,8 +67,21 @@ module PlatformosCheck
|
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
66
|
-
def file_link(partial)
|
67
|
-
|
70
|
+
def file_link(partial, platformos_app)
|
71
|
+
relative_path = platformos_app.send(app_file_type).detect { |f| f.name == partial }&.relative_path
|
72
|
+
relative_path ||= default_relative_path(partial)
|
73
|
+
|
74
|
+
file_uri(@storage.path(relative_path))
|
75
|
+
end
|
76
|
+
|
77
|
+
def default_relative_path(partial)
|
78
|
+
return Pathname.new("app/#{default_dir}/#{partial}#{default_extension}") unless partial.start_with?('modules/')
|
79
|
+
|
80
|
+
partial_components = partial.split(File::SEPARATOR)
|
81
|
+
module_prefix = partial_components.shift(2).join(File::SEPARATOR)
|
82
|
+
partial_without_module = partial_components.join(File::SEPARATOR)
|
83
|
+
|
84
|
+
Pathname.new("#{module_prefix}/public/#{default_dir}/#{partial_without_module}#{default_extension}")
|
68
85
|
end
|
69
86
|
end
|
70
87
|
end
|
data/lib/platformos_check/language_server/document_link_providers/asset_document_link_provider.rb
CHANGED
@@ -4,8 +4,8 @@ module PlatformosCheck
|
|
4
4
|
module LanguageServer
|
5
5
|
class AssetDocumentLinkProvider < DocumentLinkProvider
|
6
6
|
@partial_regexp = ASSET_INCLUDE
|
7
|
-
@
|
8
|
-
@
|
7
|
+
@app_file_type = :assets
|
8
|
+
@default_dir = 'assets'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class BackgroundDocumentLinkProvider < DocumentLinkProvider
|
6
|
+
@partial_regexp = PARTIAL_BACKGROUND
|
7
|
+
@app_file_type = :partials
|
8
|
+
@default_dir = 'lib'
|
9
|
+
@default_extension = '.liquid'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/platformos_check/language_server/document_link_providers/function_document_link_provider.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class FunctionDocumentLinkProvider < DocumentLinkProvider
|
6
|
+
@partial_regexp = PARTIAL_FUNCTION
|
7
|
+
@app_file_type = :partials
|
8
|
+
@default_dir = 'lib'
|
9
|
+
@default_extension = '.liquid'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/platformos_check/language_server/document_link_providers/graphql_document_link_provider.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class GraphqlDocumentLinkProvider < DocumentLinkProvider
|
6
|
+
@partial_regexp = PARTIAL_GRAPHQL
|
7
|
+
@app_file_type = :graphqls
|
8
|
+
@default_dir = 'graphql'
|
9
|
+
@default_extension = '.graphql'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/platformos_check/language_server/document_link_providers/include_document_link_provider.rb
CHANGED
@@ -4,8 +4,9 @@ module PlatformosCheck
|
|
4
4
|
module LanguageServer
|
5
5
|
class IncludeDocumentLinkProvider < DocumentLinkProvider
|
6
6
|
@partial_regexp = PARTIAL_INCLUDE
|
7
|
-
@
|
8
|
-
@
|
7
|
+
@app_file_type = :partials
|
8
|
+
@default_dir = 'views/partials'
|
9
|
+
@default_extension = '.liquid'
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class IncludeFormDocumentLinkProvider < DocumentLinkProvider
|
6
|
+
@partial_regexp = PARTIAL_INCLUDE_FORM
|
7
|
+
@app_file_type = :forms
|
8
|
+
@default_dir = 'forms'
|
9
|
+
@default_extension = '.liquid'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/platformos_check/language_server/document_link_providers/render_document_link_provider.rb
CHANGED
@@ -4,8 +4,9 @@ module PlatformosCheck
|
|
4
4
|
module LanguageServer
|
5
5
|
class RenderDocumentLinkProvider < DocumentLinkProvider
|
6
6
|
@partial_regexp = PARTIAL_RENDER
|
7
|
-
@
|
8
|
-
@
|
7
|
+
@app_file_type = :partials
|
8
|
+
@default_dir = 'views/partials'
|
9
|
+
@default_extension = '.liquid'
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -89,7 +89,7 @@ module PlatformosCheck
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def param_to_doc(param)
|
92
|
-
"#{param
|
92
|
+
"#{param&.name || 'object'}:#{param&.return_type&.downcase || 'untyped'}"
|
93
93
|
end
|
94
94
|
|
95
95
|
def filter_to_completion(filter)
|
@@ -97,11 +97,10 @@ module PlatformosCheck
|
|
97
97
|
first_param, *other_params = filter.parameters
|
98
98
|
other_params = other_params.map { |param| param_to_doc(param) }
|
99
99
|
other_params = other_params.any? ? ": #{other_params.join(', ')}" : ""
|
100
|
-
content
|
100
|
+
content += " \n\n#{param_to_doc(first_param)} | #{filter.name}#{other_params} => #{filter.return_type}"
|
101
101
|
|
102
102
|
{
|
103
|
-
contents: content
|
104
|
-
|
103
|
+
contents: content
|
105
104
|
# label: filter.name,
|
106
105
|
# kind: CompletionItemKinds::FUNCTION,
|
107
106
|
# **format_hash(filter),
|
@@ -15,10 +15,6 @@ module PlatformosCheck
|
|
15
15
|
true
|
16
16
|
end
|
17
17
|
|
18
|
-
def template?
|
19
|
-
name.start_with?('template')
|
20
|
-
end
|
21
|
-
|
22
18
|
def notification?
|
23
19
|
false
|
24
20
|
end
|
@@ -31,20 +27,16 @@ module PlatformosCheck
|
|
31
27
|
false
|
32
28
|
end
|
33
29
|
|
34
|
-
def
|
30
|
+
def form?
|
35
31
|
false
|
36
32
|
end
|
37
33
|
|
38
|
-
def
|
34
|
+
def partial?
|
39
35
|
false
|
40
36
|
end
|
41
37
|
|
42
|
-
def
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
def snippet?
|
47
|
-
name.start_with?('snippet')
|
38
|
+
def layout?
|
39
|
+
false
|
48
40
|
end
|
49
41
|
|
50
42
|
def rewriter
|
@@ -6,7 +6,7 @@ module PlatformosCheck
|
|
6
6
|
PARTIAL_SYNTAX = /(#{Liquid::VariableSignature}+)\s*=\s*(.*)\s*/om
|
7
7
|
CLOSE_TAG_SYNTAX = /\A(.*)(?-mix:\{%-?)\s*(\w+)\s*(.*)?(?-mix:%\})\z/m # based on Liquid::Raw::FullTokenPossiblyInvalid
|
8
8
|
|
9
|
-
attr_reader :to, :from, :attributes, :value_expr
|
9
|
+
attr_reader :to, :from, :attributes, :value_expr, :partial_syntax, :partial_name
|
10
10
|
|
11
11
|
def initialize(tag_name, markup, options)
|
12
12
|
if markup =~ PARTIAL_SYNTAX
|
@@ -17,12 +17,14 @@ module PlatformosCheck
|
|
17
17
|
after_assign_markup = Regexp.last_match(2).split('|')
|
18
18
|
parse_markup(tag_name, after_assign_markup.shift)
|
19
19
|
after_assign_markup.unshift(@to)
|
20
|
+
@partial_name = value_expr
|
20
21
|
@from = Liquid::Variable.new(after_assign_markup.join('|'), options)
|
21
22
|
else
|
22
23
|
@partial_syntax = false
|
23
24
|
parse_markup(tag_name, markup)
|
24
25
|
super
|
25
26
|
end
|
27
|
+
@attributes = attributes_expr
|
26
28
|
end
|
27
29
|
|
28
30
|
def parse(tokens)
|
data/lib/platformos_check.rb
CHANGED
@@ -17,6 +17,7 @@ require_relative "platformos_check/graphql_file"
|
|
17
17
|
require_relative "platformos_check/liquid_file"
|
18
18
|
require_relative "platformos_check/page_file"
|
19
19
|
require_relative "platformos_check/partial_file"
|
20
|
+
require_relative "platformos_check/form_file"
|
20
21
|
require_relative "platformos_check/layout_file"
|
21
22
|
require_relative "platformos_check/migration_file"
|
22
23
|
require_relative "platformos_check/sms_file"
|
data/platformos-check.gemspec
CHANGED
@@ -27,8 +27,10 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
+
spec.add_dependency('graphql', '~> 2.0.0')
|
30
31
|
spec.add_dependency('liquid', '>= 5.4.0')
|
31
32
|
spec.add_dependency('nokogiri', '>= 1.12')
|
32
33
|
spec.add_dependency('parser', '~> 3')
|
34
|
+
|
33
35
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
34
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: platformos-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Bliszczyk
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-09-
|
13
|
+
date: 2023-09-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: graphql
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 2.0.0
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: liquid
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,6 +101,8 @@ files:
|
|
87
101
|
- data/platformos_liquid/documentation/latest.json
|
88
102
|
- data/platformos_liquid/documentation/objects.json
|
89
103
|
- data/platformos_liquid/documentation/tags.json
|
104
|
+
- docker/bin/platformos-check
|
105
|
+
- docker/bin/platformos-check-language-server
|
90
106
|
- docker/check.Dockerfile
|
91
107
|
- docker/lsp.Dockerfile
|
92
108
|
- docs/api/check.md
|
@@ -166,6 +182,7 @@ files:
|
|
166
182
|
- lib/platformos_check/email_file.rb
|
167
183
|
- lib/platformos_check/exceptions.rb
|
168
184
|
- lib/platformos_check/file_system_storage.rb
|
185
|
+
- lib/platformos_check/form_file.rb
|
169
186
|
- lib/platformos_check/graphql_file.rb
|
170
187
|
- lib/platformos_check/html_check.rb
|
171
188
|
- lib/platformos_check/html_node.rb
|
@@ -202,9 +219,12 @@ files:
|
|
202
219
|
- lib/platformos_check/language_server/document_link_engine.rb
|
203
220
|
- lib/platformos_check/language_server/document_link_provider.rb
|
204
221
|
- lib/platformos_check/language_server/document_link_providers/asset_document_link_provider.rb
|
222
|
+
- lib/platformos_check/language_server/document_link_providers/background_document_link_provider.rb
|
223
|
+
- lib/platformos_check/language_server/document_link_providers/function_document_link_provider.rb
|
224
|
+
- lib/platformos_check/language_server/document_link_providers/graphql_document_link_provider.rb
|
205
225
|
- lib/platformos_check/language_server/document_link_providers/include_document_link_provider.rb
|
226
|
+
- lib/platformos_check/language_server/document_link_providers/include_form_document_link_provider.rb
|
206
227
|
- lib/platformos_check/language_server/document_link_providers/render_document_link_provider.rb
|
207
|
-
- lib/platformos_check/language_server/document_link_providers/section_document_link_provider.rb
|
208
228
|
- lib/platformos_check/language_server/execute_command_engine.rb
|
209
229
|
- lib/platformos_check/language_server/execute_command_provider.rb
|
210
230
|
- lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb
|
data/lib/platformos_check/language_server/document_link_providers/section_document_link_provider.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PlatformosCheck
|
4
|
-
module LanguageServer
|
5
|
-
class SectionDocumentLinkProvider < DocumentLinkProvider
|
6
|
-
@partial_regexp = PARTIAL_SECTION
|
7
|
-
@destination_directory = "sections"
|
8
|
-
@destination_postfix = ".liquid"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|