Skip to content

Commit

Permalink
Merge pull request #1 from Shopify/adapt_to_cli_3
Browse files Browse the repository at this point in the history
Adapt to CLI 3 and use new FE as submodule
  • Loading branch information
paulomarg committed Jun 6, 2022
2 parents 0751e50 + 41aef47 commit 50c5894
Show file tree
Hide file tree
Showing 37 changed files with 102 additions and 445 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ jobs:
SHOPIFY_API_SECRET: test-secret-key
SCOPES: read_products,write_products
HOST: app-host-name.com
APP_ENV: local
strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
defaults:
run:
working-directory: ./web
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ npm-debug.log
yarn-error.log
yarn.lock

**/node_modules

.idea
.vscode

# Ignore app.js as it is autogenerated with each JS change
web/public/js/app.js
4 changes: 0 additions & 4 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ php:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "shopify-app-template-php",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"shopify": "shopify",
"build": "shopify app build",
"dev": "shopify app dev",
"push": "shopify app push",
"scaffold": "shopify app scaffold",
"deploy": "shopify app deploy"
},
"dependencies": {
"@shopify/app": "^3.0.0",
"@shopify/cli": "^3.0.0"
}
}
3 changes: 3 additions & 0 deletions shopify.app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file stores configurations for your Shopify app.

scopes = "write_products"
6 changes: 0 additions & 6 deletions web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ APP_NAME="Shopify PHP App"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug
Expand All @@ -11,8 +10,3 @@ DB_CONNECTION=sqlite
# The path to the database file should be absolute, make sure to update it!
DB_DATABASE=storage/db.sqlite
DB_FOREIGN_KEYS=true

SHOPIFY_API_KEY=
SHOPIFY_API_SECRET=
SCOPES=
HOST=
6 changes: 3 additions & 3 deletions web/app/Http/Middleware/EnsureShopifySession.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function handle(Request $request, Closure $next, string $accessMode = sel

if ($session && $shop && $session->getShop() !== $shop) {
// This request is for a different shop. Go straight to login
return redirect("/login?shop=$shop");
return redirect("/api/auth?shop=$shop");
}

if ($session && $session->isValid()) {
Expand Down Expand Up @@ -83,10 +83,10 @@ public function handle(Request $request, Closure $next, string $accessMode = sel

return response('', 401, [
self::REDIRECT_HEADER => '1',
self::REDIRECT_URL_HEADER => "/login?shop=$shop",
self::REDIRECT_URL_HEADER => "/api/auth?shop=$shop",
]);
} else {
return redirect("/login?shop=$shop");
return redirect("/api/auth?shop=$shop");
}
}
}
4 changes: 2 additions & 2 deletions web/app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
'graphql',
'webhooks',
'api/graphql',
'api/webhooks',
];
}
11 changes: 7 additions & 4 deletions web/app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ public function register()
*/
public function boot()
{
$host = str_replace('https://', '', env('HOST', 'not_defined'));

Context::initialize(
Config::get('shopify.api_key'),
Config::get('shopify.api_secret'),
Config::get('shopify.scopes'),
str_replace('https://', '', Config::get('shopify.host')),
env('SHOPIFY_API_KEY', 'not_defined'),
env('SHOPIFY_API_SECRET', 'not_defined'),
env('SCOPES', 'not_defined'),
$host,
new DbSessionStorage()
);

URL::forceRootUrl("https://$host");
URL::forceScheme('https');

Registry::addHandler(Topics::APP_UNINSTALLED, new AppUninstalled());
Expand Down
4 changes: 2 additions & 2 deletions web/artisan
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ define('LARAVEL_START', microtime(true));
|
*/

require __DIR__.'/vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';
$app = require_once __DIR__ . '/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions web/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"serve": "php artisan serve",
"serve": "php artisan serve --port=\"${BACKEND_PORT:-$PORT}\"",
"react": "npm run watch",
"test": "php artisan test --env=testing",
"lint": "./vendor/bin/phpcs --standard=PSR12 app tests routes"
"lint": "./vendor/bin/phpcs --standard=PSR12 app tests routes",
"build-frontend-links": "ln -sf ../frontend/dist/assets public/assets && ln -sf ../frontend/dist/index.html public/index.html"
},
"extra": {
"laravel": {
Expand Down
2 changes: 1 addition & 1 deletion web/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
|
*/

'url' => env('APP_URL', 'http://localhost'),
'url' => env('HOST', 'http://localhost'),

'asset_url' => env('ASSET_URL', null),

Expand Down
8 changes: 0 additions & 8 deletions web/config/shopify.php

This file was deleted.

2 changes: 1 addition & 1 deletion web/frontend
1 change: 1 addition & 0 deletions web/public/assets
1 change: 0 additions & 1 deletion web/public/css/app.css

This file was deleted.

1 change: 1 addition & 0 deletions web/public/index.html
8 changes: 4 additions & 4 deletions web/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
|
*/

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
if (file_exists(__DIR__ . '/../storage/framework/maintenance.php')) {
require __DIR__ . '/../storage/framework/maintenance.php';
}

/*
Expand All @@ -31,7 +31,7 @@
|
*/

require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
Expand All @@ -44,7 +44,7 @@
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';

$kernel = $app->make(Kernel::class);

Expand Down
4 changes: 0 additions & 4 deletions web/public/mix-manifest.json

This file was deleted.

2 changes: 0 additions & 2 deletions web/resources/js/app.js

This file was deleted.

28 changes: 0 additions & 28 deletions web/resources/js/bootstrap.js

This file was deleted.

84 changes: 0 additions & 84 deletions web/resources/js/react/App.jsx

This file was deleted.

38 changes: 0 additions & 38 deletions web/resources/js/react/components/AppNavigation.jsx

This file was deleted.

10 changes: 0 additions & 10 deletions web/resources/js/react/components/ClientRouter.jsx

This file was deleted.

Loading

0 comments on commit 50c5894

Please sign in to comment.