Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retire blocks plugin #54

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 2 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ jobs:
name: Extract tests artifacts
when: always
command: |
mkdir -p /home/circleci/artifacts/playwright/themes /home/circleci/artifacts/playwright/plugins
cp -r planet4/themes/planet4-master-theme/e2e-* /home/circleci/artifacts/playwright/themes || true
cp planet4/themes/planet4-master-theme/results.xml /home/circleci/artifacts/playwright/themes || true
cp -r planet4/plugins/planet4-plugin-gutenberg-blocks/e2e-* /home/circleci/artifacts/playwright/plugins || true
cp planet4/plugins/planet4-plugin-gutenberg-blocks/results.xml /home/circleci/artifacts/playwright/plugins || true
cp -r planet4/themes/planet4-master-theme/e2e-* /home/circleci/artifacts/playwright || true
cp planet4/themes/planet4-master-theme/results.xml /home/circleci/artifacts/playwright || true
- store_test_results:
path: /home/circleci/artifacts
- store_artifacts:
Expand Down
3 changes: 1 addition & 2 deletions .p4-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
},
"repos": {
"planet4-base": "main",
"planet4-master-theme": "main",
"planet4-plugin-gutenberg-blocks": "main"
"planet4-master-theme": "main"
},
"composer": {
"processTimeout": "600"
Expand Down
4 changes: 0 additions & 4 deletions scripts/clean-repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ const {isDir, isRepo} = require('./lib/utils');

const config = getConfig();
const themeDir = `${config.themesDir}/planet4-master-theme`;
const pluginDir = `${config.pluginsDir}/planet4-plugin-gutenberg-blocks`;

if (isDir(themeDir) && !isRepo(themeDir)) {
run(`sudo rm -rf ${themeDir}`);
}
if (isDir(pluginDir) && !isRepo(pluginDir)) {
run(`sudo rm -rf ${pluginDir}`);
}
6 changes: 0 additions & 6 deletions scripts/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,10 @@ if (args.command === 'install') {
run(`npx playwright install ${args.options.join(' ')}`, {
cwd: `${config.paths.local.themes}/planet4-master-theme`,
});
run(`npx playwright install ${args.options.join(' ')}`, {
cwd: `${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`,
});
}

if (args.command === 'run') {
run(`npx playwright test ${args.options.join(' ')} --pass-with-no-tests`, {
cwd: `${config.paths.local.themes}/planet4-master-theme`,
});
run(`npx playwright test ${args.options.join(' ')} --pass-with-no-tests`, {
cwd: `${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`,
});
}
3 changes: 0 additions & 3 deletions scripts/fix-permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ if (all) {
run(
`sudo find ${config.paths.local.themes}/planet4-master-theme -not -user $(whoami) -exec chown -f $(whoami) {} \\+`
);
run(
`sudo find ${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks -not -user $(whoami) -exec chown -f $(whoami) {} \\+`
);
}
9 changes: 0 additions & 9 deletions scripts/lib/composer-requirements.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ function generateBaseComposerRequirements(config) {
);
}

if (
isDir(`${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`)
) {
composer(
'remove --no-update greenpeace/planet4-plugin-gutenberg-blocks',
config.paths.container.app
);
}

composer(
'remove --no-update greenpeace/planet4-nginx-helper',
config.paths.container.app
Expand Down
26 changes: 0 additions & 26 deletions scripts/lib/gpi-frontend.code-workspace

This file was deleted.

35 changes: 1 addition & 34 deletions scripts/lib/main-repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,77 +29,47 @@ function getMainReposFromGit(config) {
} || true`,
{cwd: themePath}
);

const pluginPath = `${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`;
if(isRepo(pluginPath)) {
run('git status', {cwd: pluginPath});
} else {
run(`rm -rf ${pluginPath} && git clone --recurse-submodules --shallow-submodule https://github.com/greenpeace/planet4-plugin-gutenberg-blocks.git ${pluginPath}`);
}

run(
`git checkout ${
config.planet4.repos['planet4-plugin-gutenberg-blocks'] || 'main'
} || true`,
{cwd: pluginPath}
);
}

function getMainReposFromRelease(config, force = false) {
if (
!force &&
isDir(`${config.paths.local.themes}/planet4-master-theme`) &&
isDir(`${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`)
isDir(`${config.paths.local.themes}/planet4-master-theme`)
) {
return;
}

const themeRelease =
'https://github.com/greenpeace/planet4-master-theme/releases/latest/download/planet4-master-theme.zip';
const pluginRelease =
'https://github.com/greenpeace/planet4-plugin-gutenberg-blocks/releases/latest/download/planet4-plugin-gutenberg-blocks.zip';

run(`curl -L ${themeRelease} > content/planet4-master-theme.zip`);
run(
`curl -L ${pluginRelease} > content/planet4-plugin-gutenberg-blocks.zip`
);

run(
`mkdir -p ${config.paths.local.themes} && mkdir -p ${config.paths.local.plugins}`
);
run(
`unzip -o content/planet4-master-theme.zip -d ${config.paths.local.themes}/planet4-master-theme`
);
run(
`unzip -o content/planet4-plugin-gutenberg-blocks.zip -d ${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`
);
}

function installRepos(config) {
// composer(`config platform.php "${config.phpVersion}"`, `/app/${config.themesDir}/planet4-master-theme `)
composer(
'install',
`${config.paths.container.themes}/planet4-master-theme `
);
// composer(`config platform.php "${config.phpVersion}"`, `/app/${config.pluginsDir}/planet4-plugin-gutenberg-blocks`)
composer('install', `${config.paths.container.plugins}/planet4-plugin-gutenberg-blocks`);
}

function installNpmDependencies (config) {
process.env.PUPPETEER_SKIP_DOWNLOAD = true;
process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = true;
run('npm install --legacy-peer-deps', {cwd: `${config.paths.local.themes}/planet4-master-theme`});
run('npm install', {cwd: `${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`});
}

function buildAssets(config, force = false) {
if (
!force &&
isDir(
`${config.paths.local.themes}/planet4-master-theme/assets/build`
) &&
isDir(
`${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks/assets/build`
)
) {
return;
Expand All @@ -109,9 +79,6 @@ function buildAssets(config, force = false) {
run('npm run build', {
cwd: `${config.paths.local.themes}/planet4-master-theme`,
});
run('npm run build', {
cwd: `${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`,
});
}

function setComposerConfig (config) {
Expand Down
1 change: 0 additions & 1 deletion scripts/nro-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ if (theme) {
}

composer('update', config.paths.container.app);
// installPluginsDependencies(config)
if (themeName) {
wp(`theme activate ${themeName}`);
}
Expand Down
4 changes: 0 additions & 4 deletions scripts/php-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ const {parseArgs} = require('./lib/utils');
const config = getConfig();
const rootPath = config.paths.container.app.replace('/wp-content', '');
const themePath = `${rootPath}/${config.paths.container.themes}/planet4-master-theme`;
const pluginPath = `${rootPath}/${config.paths.container.plugins}/planet4-plugin-gutenberg-blocks`;

const args = parseArgs(process.argv, {command: 'lint'}); // lint, fix, test

if (args.command === 'lint') {
runInWpContainer('./vendor/bin/phpcs src/ page-templates/ tests/', {working_dir: themePath});
runInWpContainer('./vendor/bin/phpcs classes/', {working_dir: pluginPath});
}

if (args.command === 'fix') {
runInWpContainer('./vendor/bin/phpcbf src/ page-templates/ tests/', {working_dir: themePath});
runInWpContainer('./vendor/bin/phpcbf classes/', {working_dir: pluginPath});
}

if (args.command === 'test') {
runInWpContainer('./vendor/bin/phpunit', {working_dir: themePath});
runInWpContainer('./vendor/bin/phpunit', {working_dir: pluginPath});
}
9 changes: 2 additions & 7 deletions scripts/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,14 @@ if (isRepo(`${config.paths.local.app}/planet4-base`)) {

// main repos
if (
isRepo(`${config.paths.local.themes}/planet4-master-theme`) &&
isRepo(`${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`)
isRepo(`${config.paths.local.themes}/planet4-master-theme`)
) {
run('git pull || true', {
cwd: `${config.paths.local.themes}/planet4-master-theme`,
});
run('git pull || true', {
cwd: `${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`,
});
installRepos(config);
} else if (
isDir(`${config.paths.local.themes}/planet4-master-theme`) &&
isDir(`${config.paths.local.plugins}/planet4-plugin-gutenberg-blocks`)
isDir(`${config.paths.local.themes}/planet4-master-theme`)
) {
getMainReposFromRelease(config, true);
installRepos(config);
Expand Down