Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- wp-launchpad/ajax
- wp-launchpad/cron
- wp-launchpad/context
- wp-launchpad/front-take-off

name: ${{ matrix.component }} WP ${{ matrix.wp-versions }} with PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}.

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"wp-launchpad/renderer": "self.version",
"wp-launchpad/filesystem": "self.version",
"wp-launchpad/uninstaller": "self.version",
"wp-launchpad/front": "self.version",
"wp-launchpad/bud-assets": "self.version",
"wp-launchpad/dispatcher": "self.version"
},
"config": {
Expand Down
3 changes: 3 additions & 0 deletions packages/front-take-off/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
.idea
composer.lock
49 changes: 49 additions & 0 deletions packages/front-take-off/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "wp-launchpad/front-take-off",
"description": "Front-end initialisation library for the Launchpad framework",
"minimum-stability": "stable",
"license": "proprietary",
"type": "library",
"authors": [
{
"name": "coquardcyr",
"email": "coquardcyr@gmail.com"
}
],
"require": {
"wp-launchpad/cli": "^3.1",
"ext-mbstring": "*",
"ext-json": "*",
"composer/composer": "^2.5"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8 || ^9",
"wp-media/phpunit": "^3.0",
"wp-launchpad/front": "^3.1"
},
"autoload": {
"psr-4": {
"LaunchpadFrontTakeOff\\": "inc/"
}
},
"autoload-dev": {
"psr-4": {
"LaunchpadFrontTakeOff\\Tests\\": "tests/"
}
},
"extra": {
"launchpad": {
"provider" : "LaunchpadFrontTakeOff\\ServiceProvider",
"command": "front:install",
"libraries": {
"wp-launchpad/front": "^3.1"
}
}
},
"scripts": {
"test-integration": "\"vendor/bin/phpunit\" --testsuite integration --colors=always --configuration tests/Integration/phpunit.xml.dist --exclude-group AdminOnly",
"run-tests": [
"@test-integration"
]
}
}
3 changes: 3 additions & 0 deletions packages/front-take-off/front/react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.budfiles
package-lock.json
1 change: 1 addition & 0 deletions packages/front-take-off/front/react/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
17 changes: 17 additions & 0 deletions packages/front-take-off/front/react/bud.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @typedef {import('@roots/bud').Bud} Bud
*
* @param {Bud} bud
*/
module.exports = async bud => {
bud.externals({
jQuery: 'window.jquery',
wp: 'window.wp',
})
await bud
.setPath('@dist', '../assets')
.entry({
app: 'app.js',
})
.when( bud.isProduction, () => bud.splitChunks().minimize() )
}
27 changes: 27 additions & 0 deletions packages/front-take-off/front/react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "launchpad-front",
"version": "1.0.0",
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"scripts": {
"dev": "bud dev",
"build": "bud build",
"bud": "bud"
},
"devDependencies": {
"-": "0.0.1",
"@roots/bud": "^6.11.0",
"@roots/bud-react": "^6.11.0",
"caniuse-lite": "^1.0.30001464"
}
}
7 changes: 7 additions & 0 deletions packages/front-take-off/front/react/src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

function App(props) {
return <div></div>;
}

export default App;
11 changes: 11 additions & 0 deletions packages/front-take-off/front/react/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import App from "./App";
import React from 'react';
import {createRoot} from 'react-dom/client';

jQuery(function () {
const root = document.getElementById('app');

if(root){
createRoot(root).render(<App />);
}
});
3 changes: 3 additions & 0 deletions packages/front-take-off/front/vanilla/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.budfiles
package-lock.json
1 change: 1 addition & 0 deletions packages/front-take-off/front/vanilla/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
18 changes: 18 additions & 0 deletions packages/front-take-off/front/vanilla/bud.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @typedef {import('@roots/bud').Bud} Bud
*
* @param {Bud} bud
*/
module.exports = async bud => {
bud.externals({
jQuery: 'window.jquery',
wp: 'window.wp',
react: 'window.React'
})
await bud
.setPath('@dist', '../assets')
.entry({
app: 'app.js',
})
.when( bud.isProduction, () => bud.splitChunks().minimize() )
}
27 changes: 27 additions & 0 deletions packages/front-take-off/front/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "launchpad-front",
"version": "1.0.0",
"dependencies": {},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"scripts": {
"dev": "bud dev",
"build": "bud build",
"bud": "bud"
},
"devDependencies": {
"-": "0.0.1",
"@roots/bud": "^6.11.0",
"caniuse-lite": "^1.0.30001464"
}
}
1 change: 1 addition & 0 deletions packages/front-take-off/front/vanilla/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions packages/front-take-off/front/vue/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.budfiles
package-lock.json
1 change: 1 addition & 0 deletions packages/front-take-off/front/vue/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
17 changes: 17 additions & 0 deletions packages/front-take-off/front/vue/bud.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @typedef {import('@roots/bud').Bud} Bud
*
* @param {Bud} bud
*/
module.exports = async bud => {
bud.externals({
jQuery: 'window.jquery',
wp: 'window.wp',
})
await bud
.setPath('@dist', '../assets')
.entry({
app: 'app.js',
})
.when( bud.isProduction, () => bud.splitChunks().minimize() )
}
27 changes: 27 additions & 0 deletions packages/front-take-off/front/vue/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "launchpad-front",
"version": "1.0.0",
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"scripts": {
"dev": "bud dev",
"build": "bud build",
"bud": "bud"
},
"devDependencies": {
"-": "0.0.1",
"@roots/bud": "^6.11.0",
"@roots/bud-vue": "^6.11.0",
"caniuse-lite": "^1.0.30001464"
}
}
2 changes: 2 additions & 0 deletions packages/front-take-off/front/vue/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<template>
</template>
6 changes: 6 additions & 0 deletions packages/front-take-off/front/vue/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createApp } from "vue";
import App from "./App";

const app = createApp(App);

app.mount("#app");
85 changes: 85 additions & 0 deletions packages/front-take-off/inc/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace LaunchpadFrontTakeOff\Commands;

use Ahc\Cli\IO\Interactor;
use LaunchpadCLI\Commands\Command;
use LaunchpadCLI\ObjectValues\InvalidValue;
use LaunchpadFrontTakeOff\ObjectValues\FrontVersion;
use LaunchpadFrontTakeOff\Services\ConfigsManager;
use LaunchpadFrontTakeOff\Services\FrontEndInstallationManage;
use LaunchpadFrontTakeOff\Services\ProjectManager;

class InstallCommand extends Command
{

/**
* @var FrontEndInstallationManage
*/
protected $front_end_installation_manage;

/**
* @var ProjectManager
*/
protected $project_manager;

/**
* @var ConfigsManager
*/
protected $configs_manager;

/**
* Instantiate the class.
*
* @param FrontEndInstallationManage $front_end_installation_manage
* @param ProjectManager $project_manager
* @param ConfigsManager $configs_manager
*/
public function __construct(FrontEndInstallationManage $front_end_installation_manage, ProjectManager $project_manager, ConfigsManager $configs_manager)
{
parent::__construct('front:install', 'Install a frontend');

$this->front_end_installation_manage = $front_end_installation_manage;
$this->project_manager = $project_manager;
$this->configs_manager = $configs_manager;

$this
->argument('[type]', 'Type from the frontend to install')
// Usage examples:
->usage(
// append details or explanation of given example with ` ## ` so they will be uniformly aligned when shown
'<bold> $0 front:install</end> <comment>react </end> ## Install a frontend<eol/>'
);
}

public function interact(Interactor $io)
{
// Collect missing opts/args
if (!$this->type) {

$types = [
FrontVersion::REACT => 'React',
FrontVersion::VANILLA => 'Vanilla',
FrontVersion::VUE => 'Vue',
];

$this->set('type', $io->choice('Select a frontend', $types, 'vanilla'));
}
}

public function execute($type) {
$io = $this->app()->io();

try {
$type = new FrontVersion($type);
} catch (InvalidValue $value) {
$io->error('The type of frontend is not valid');
return;
}

$this->front_end_installation_manage->create_template_folder();
$this->front_end_installation_manage->move_front_assets($type);
$this->configs_manager->set_up_provider();
$this->project_manager->cleanup();
}
}
Loading
Loading