Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Init platformos #741

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ packaging/builds
.vscode
*.DS_Store

.ruby-version
.ruby-gemset

# Theme Liquid docs live at [email protected]:Shopify/theme-liquid-docs.git,
/data/shopify_liquid/documentation/
5 changes: 1 addition & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
inherit_gem:
rubocop-shopify: rubocop.yml

require:
- rubocop-performance
- rubocop-minitest
- rubocop-rake

AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 3.2
Exclude:
- 'vendor/bundle/**/*'
- 'packaging/builds/**/*'
Expand Down
457 changes: 2 additions & 455 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at opensource@shopify.com. All
reported by contacting the project team at support@platformos.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand All @@ -67,7 +67,7 @@ members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
This Code of Conduct is adapted from Shopify's theme-check, which adapted it from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
Expand Down
83 changes: 34 additions & 49 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Contributing to Theme Check

We love receiving pull requests!

For your contribution to be accepted you will need to sign the [Shopify Contributor License Agreement (CLA)](https://cla.shopify.com/).
# Contributing to platformOS Check

## Standards

Expand All @@ -15,14 +11,15 @@ For your contribution to be accepted you will need to sign the [Shopify Contribu

## How to contribute

1. Fork it ( https://github.com/Shopify/theme-check/fork )
1. Fork it ( https://github.com/Platform-OS/platformos-lsp )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Run Language Server
If you're making changes to the language server and you want to debug, you can run the repo's version of `theme-check-language-server`.
## Run Language Server

If you're making changes to the language server and you want to debug, you can run the repo's version of `platformos-check-language-server`.

### Setup

Expand All @@ -32,52 +29,40 @@ Before configuring your IDE, run the following commands in a terminal:
```bash
mkdir -p $HOME/bin
```
* Paste this script to create an executable wrapper in `$HOME/bin/theme-check-language-server` for language server
* Paste this script to create an executable wrapper in `$HOME/bin/platformos-check-language-server` for language server
```bash
cat <<-'EOF' > $HOME/bin/theme-check-language-server
cat <<-'EOF' > $HOME/bin/platformos-check-language-server
#!/usr/bin/env bash
cd "$HOME/src/github.com/Shopify/theme-check" &> /dev/null
chruby () {
source '/opt/dev/sh/chruby/chruby.sh'
chruby "$@"
}
export THEME_CHECK_DEBUG=true
export THEME_CHECK_DEBUG_LOG_FILE="/tmp/theme-check-debug.log"
touch "$THEME_CHECK_DEBUG_LOG_FILE"
chruby 2.7 &>/dev/null
cd "$HOME/src/github.com/Platform-OS/platformos-lsp" &> /dev/null
export PLATFORMOS_CHECK_DEBUG=true
export PLATFORMOS_CHECK_DEBUG_LOG_FILE="/tmp/platformos-check-debug.log"
touch "$PLATFORMOS_CHECK_DEBUG_LOG_FILE"
gem env &>/dev/null
bin/theme-check-language-server
bin/platformos-check-language-server
EOF
```
* Make the script executable
```bash
chmod u+x $HOME/bin/theme-check-language-server
chmod u+x $HOME/bin/platformos-check-language-server
```

#### Configure VS Code

* Install the [Shopify Liquid](https://github.com/shopify/theme-check-vscode) plugin

* Add the following to `settings.json`:

```json
"shopifyLiquid.formatterDevPreview": true,
"shopifyLiquid.languageServerPath": "/Users/<YOUR_USERNAME>/bin/theme-check-language-server",
```
TODO

#### Configure Vim

If you use `coc.nvim` as your completion engine, add this to your CocConfig:

```json
"languageserver": {
"theme-check": {
"command": "/Users/<YOUR_USERNAME>/bin/theme-check-language-server",
"platformos-check": {
"command": "/Users/<YOUR_USERNAME>/bin/platformos-check-language-server",
"trace.server": "verbose",
"filetypes": ["liquid", "liquid.html"],
"rootPatterns": [".theme-check.yml", "snippets/*"],
"filetypes": ["liquid"],
"rootPatterns": [".platformos-check.yml, .pos"],
"settings": {
"themeCheck": {
"platformosCheck": {
"checkOnSave": true,
"checkOnEnter": true,
"checkOnChange": false
Expand All @@ -88,12 +73,12 @@ If you use `coc.nvim` as your completion engine, add this to your CocConfig:

### Confirm Setup

* In another terminal from the root of theme check run `tail -f /tmp/theme-check-debug.log` to watch the server logs
* In another terminal from the root of theme check run `tail -f /tmp/platformos-check-debug.log` to watch the server logs
* Restart your IDE, confirm the response for initialize in the logs is pointing to the language server in the `$HOME/bin` directory (the version will be different)

```json
"serverInfo": {
"name": "/Users/johndoe/bin/theme-check-language-server",
"name": "/Users/johndoe/bin/platformos-check-language-server",
"version": "1.10.3"
}
```
Expand All @@ -102,21 +87,21 @@ If you use `coc.nvim` as your completion engine, add this to your CocConfig:
## Running Tests

```
bundle install # Or `dev up` if you're from Shopify
bundle install
bundle exec rake
```

## Checking a theme
## Checking a pOS app

```
bin/theme-check /path/to/your/theme
bin/platformos-check /path/to/your/app
```

## Creating a new "Check"

Run `bundle exec rake "new_check[MyNewCheckName]"` to generate all the files required to create a new check.

Check the [Check API](/docs/api/check.md) for how to implement a check. Also take a look at other checks in [lib/theme_check/checks](/lib/theme_check/checks).
Check the [Check API](/docs/api/check.md) for how to implement a check. Also take a look at other checks in [lib/platformos_check/checks](/lib/platformos_check/checks).

We done implementing your check, add it to `config/default.yml` to enable it:

Expand Down Expand Up @@ -146,23 +131,23 @@ MyNewCheckName:

## Debugging

A couple of things are turned on when the `THEME_CHECK_DEBUG` environment variable is set.
A couple of things are turned on when the `PLATFORMOS_CHECK_DEBUG` environment variable is set.

1. The check timeout is turned off. This means you can add `binding.pry` in tests and properly debug with `bundle exec rake tests:in_memory`
2. The `--profile` flag appears. You can now create Flamegraphs to inspect performance.

```
export THEME_CHECK_DEBUG=true
export PLATFORMOS_CHECK_DEBUG=true

# The following will behave slightly differently
bin/theme-check ../dawn
bin/platformos-check ../dawn
bundle exec rake tests:in_memory

# The following becomes available
bin/theme-check --profile ../dawn
bin/platformos-check --profile ../dawn

# The LanguageServer will log the JSONRPC calls to STDERR
bin/theme-check-language-server
bin/platformos-check-language-server
```

### Profiling
Expand All @@ -171,10 +156,10 @@ bin/theme-check-language-server

#### Flamegraph

With the `--profile` flag, you can run theme-check on a theme and the `ruby-prof-flamegraph` printer will output profiling information in a format [Flamegraph](/brendangregg/FlameGraph) understands.
With the `--profile` flag, you can run platformos-check on a theme and the `ruby-prof-flamegraph` printer will output profiling information in a format [Flamegraph](/brendangregg/FlameGraph) understands.


**Setup:**
**Setup:**

```bash
# clone the FlameGraph repo somewhere
Expand All @@ -187,10 +172,10 @@ alias flamegraph=/path/to/FlameGraph/flamegraph.pl
**Profiling:**

```
# run theme-check with --profile
# run platformos-check with --profile
# pass the output to flamegraph
# dump the output into an svg file
bin/theme-check --profile ../dawn \
bin/platformos-check --profile ../dawn \
| flamegraph --countname=ms --width=1750 \
> /tmp/fg.svg

Expand Down
11 changes: 5 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in theme-check.gemspec
# Specify your gem's dependencies in platformos-check.gemspec
gemspec

gem 'bundler'
Expand All @@ -24,8 +24,7 @@ group :development do
gem 'solargraph'
end

gem 'rubocop', '~> 1.12.0', require: false
gem 'rubocop-performance', '~> 1.10.2', require: false
gem 'rubocop-shopify', '~> 1.0.7', require: false
gem 'rubocop-minitest', '~> 0.11.0', require: false
gem 'rubocop-rake', '~> 0.5.1', require: false
gem 'rubocop', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-minitest', require: false
gem 'rubocop-rake', require: false
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

guard :minitest do
watch(%r{^test/(.*)_test.rb$})
watch(%r{^lib/theme_check/(.*)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^lib/platformos_check/(.*)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
end
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Copyright 2020-present, Shopify Inc.
Copyright 2023-present, platformOS.

Contains code from activesupport Copyright (c) 2005-2019 David Heinemeier Hansson

Expand Down
Loading
Loading