tools/create-extension: Remove old tool (#44374)

remove tools/create-extension
This commit is contained in:
Paul Sealock 2024-02-06 10:47:31 +13:00 committed by GitHub
parent 26bcbb0417
commit 73f098b563
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 0 additions and 336 deletions

View File

@ -26,7 +26,6 @@
"preinstall": "npx only-allow pnpm",
"postinstall": "pnpm git:update-hooks",
"git:update-hooks": "if test -d .git; then rm -rf .git/hooks && mkdir -p .git/hooks && husky install; else husky install; fi",
"create-extension": "node ./tools/create-extension/index.js",
"sync-dependencies": "pnpm exec syncpack -- fix-mismatches",
"utils": "./tools/monorepo-utils/bin/run"
},

View File

@ -5,7 +5,6 @@ packages:
- 'tools/monorepo-merge'
- 'tools/code-analyzer'
- 'tools/compare-perf'
- 'tools/create-extension'
- 'tools/package-release'
- 'tools/cherry-pick'
- 'tools/release-posts'

View File

@ -1,10 +0,0 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
rules: {
// temporary conversion to warnings until the below are all handled.
'jsdoc/check-tag-names': [
'error',
{ definedTags: [ 'jest-environment' ] },
],
},
};

View File

@ -1,23 +0,0 @@
# Directories/files that may be generated by this project
node_modules/
dist
build
build-module
build-style
languages/*
!languages/README.md
# Directories/files that may appear in your environment
.DS_Store
Thumbs.db
wp-cli.local.yml
*.sql
*.tar.gz
*.tgz
*.zip
.idea
.vscode/
# Composer
/vendor/

View File

@ -1 +0,0 @@
"@wordpress/prettier-config"

View File

@ -1,14 +0,0 @@
{
"phpVersion": "7.4",
"core": null,
"plugins": [
"https://downloads.wordpress.org/plugin/woocommerce.6.3.1.zip",
"."
],
"config": {
"JETPACK_AUTOLOAD_DEV": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": true,
"ALTERNATE_WP_CRON": true
}
}

View File

@ -1,22 +0,0 @@
# Create Extension
Scaffold a modern JavaScript WordPress plugin with WooCommerce tooling.
## Includes
- [wp-scripts](https://github.com/WordPress/gutenberg/tree/master/packages/scripts)
- [WooCommerce Dependency Extraction Webpack Plugin](https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/dependency-extraction-webpack-plugin)
- [WooCommerce ESLint Plugin with WordPress Prettier](https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/eslint-plugin)
### Usage
```
pnpm create-extension
```
The script will create a sibling directory by a name of your choosing. Once you change directories into the new folder, install dependencies and start a development build.
```
pnpm install
pnpm start
```

View File

@ -1,14 +0,0 @@
# {{extension_name}}
A WooCommerce Admin Extension
## Development
To get started, run the following commands:
```text
npm install
npm start
```
See [wp-scripts](https://github.com/WordPress/gutenberg/tree/master/packages/scripts) for more usage information.

View File

@ -1,69 +0,0 @@
<?php
/**
* Plugin Name: {{extension_name}}
*
* @package WooCommerce\Admin
*/
/**
* Register the JS and CSS.
*/
function add_extension_register_script() {
if (
! method_exists( 'Automattic\WooCommerce\Admin\PageController', 'is_admin_or_embed_page' ) ||
! \Automattic\WooCommerce\Admin\PageController::is_admin_or_embed_page()
) {
return;
}
$script_path = '/build/index.js';
$script_asset_path = dirname( __FILE__ ) . '/build/index.asset.php';
$script_asset = file_exists( $script_asset_path )
? require( $script_asset_path )
: array( 'dependencies' => array(), 'version' => filemtime( $script_path ) );
$script_url = plugins_url( $script_path, __FILE__ );
wp_register_script(
'{{extension_slug}}',
$script_url,
$script_asset['dependencies'],
$script_asset['version'],
true
);
wp_register_style(
'{{extension_slug}}',
plugins_url( '/build/index.css', __FILE__ ),
// Add any dependencies styles may have, such as wp-components.
array(),
filemtime( dirname( __FILE__ ) . '/build/index.css' )
);
wp_enqueue_script( '{{extension_slug}}' );
wp_enqueue_style( '{{extension_slug}}' );
}
add_action( 'admin_enqueue_scripts', 'add_extension_register_script' );
/**
* Register a WooCommerce Admin page.
*/
function add_extension_register_page() {
if ( ! function_exists( 'wc_admin_register_page' ) ) {
return;
}
wc_admin_register_page( array(
'id' => 'my-example-page',
'title' => __( 'My Example Page', 'my-textdomain' ),
'parent' => 'woocommerce',
'path' => '/example',
'nav_args' => array(
'order' => 10,
'parent' => 'woocommerce',
),
) );
}
add_action( 'admin_menu', 'add_extension_register_page' );

View File

@ -1,30 +0,0 @@
{
"name": "{{extension_slug}}",
"title": "{{extension_name}}",
"license": "GPL-3.0-or-later",
"version": "0.0.1",
"description": "{{extension_name}}",
"scripts": {
"build": "wp-scripts build",
"check-engines": "wp-scripts check-engines",
"check-licenses": "wp-scripts check-licenses",
"format:js": "wp-scripts format-js",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:md:docs": "wp-scripts lint-md-docs",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"packages-update": "wp-scripts packages-update",
"start": "wp-scripts start",
"test:e2e": "wp-scripts test-e2e",
"test:unit": "wp-scripts test-unit-js"
},
"devDependencies": {
"@wordpress/scripts": "^26.10.0",
"@woocommerce/eslint-plugin": "latest",
"@woocommerce/dependency-extraction-webpack-plugin": "1.6.0",
"prettier": "^2.8.8"
},
"dependencies": {
"@wordpress/hooks": "^3.5.0"
}
}

View File

@ -1,13 +0,0 @@
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
module.exports = {
...defaultConfig,
plugins: [
...defaultConfig.plugins.filter(
( plugin ) =>
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new WooCommerceDependencyExtractionWebpackPlugin(),
],
};

View File

@ -1,91 +0,0 @@
const fs = require( 'fs-extra' );
const path = require( 'path' );
const promptly = require( 'promptly' );
const chalk = require( 'chalk' );
const files = [
'._gitignore',
'_README.md',
'_webpack.config.js',
'_main.php',
'_package.json',
'._eslintrc.js',
'._prettierrc.json',
'._wp-env.json',
];
const maybeThrowError = ( error ) => {
if ( error ) throw error;
};
( async () => {
console.log( '\n' );
console.log(
chalk.yellow(
'🎉 Welcome to WooCommerce Admin Extension Starter Pack 🎉'
)
);
console.log( '\n' );
const extensionName = await promptly.prompt(
chalk.yellow( 'What is the name of your extension?' )
);
const extensionSlug = extensionName.replace( / /g, '-' ).toLowerCase();
const folder = path.join( __dirname, extensionSlug );
fs.mkdir( folder, maybeThrowError );
files.forEach( ( file ) => {
const from = path.join( __dirname, file );
const to = path.join(
folder,
file === '_main.php'
? `${ extensionSlug }.php`
: file.replace( '_', '' )
);
fs.readFile( from, 'utf8', ( error, data ) => {
maybeThrowError( error );
const addSlugs = data.replace(
/{{extension_slug}}/g,
extensionSlug
);
const result = addSlugs.replace(
/{{extension_name}}/g,
extensionName
);
fs.writeFile( to, result, 'utf8', maybeThrowError );
} );
} );
fs.copy(
path.join( __dirname, 'src' ),
path.join( folder, 'src' ),
maybeThrowError
);
fs.copy( folder, path.join( '../', extensionSlug ), ( error ) => {
maybeThrowError( error );
fs.remove( folder, maybeThrowError );
} );
process.stdout.write( '\n' );
console.log(
chalk.green(
'Wonderful, your extension has been scaffolded and placed as a sibling directory to this one.'
)
);
process.stdout.write( '\n' );
console.log(
chalk.green(
'Run the following commands from the root of the extension to scaffold a dev environment.'
)
);
process.stdout.write( '\n' );
console.log( 'wp-env start' );
console.log( 'pnpm install' );
console.log( 'pnpm start' );
process.stdout.write( '\n' );
} )();

View File

@ -1,22 +0,0 @@
{
"name": "create-extension",
"version": "0.0.0",
"description": "A tool to scaffold out an Admin ready WooCommerce extension",
"author": "Automattic",
"homepage": "https://github.com/woocommerce/woocommerce",
"license": "GPLv2",
"main": "index.js",
"repository": "woocommerce/woocommerce",
"dependencies": {
"chalk": "^4.1.2",
"fs-extra": "10.1.0",
"promptly": "^3.2.0"
},
"engines": {
"node": "^16.14.1",
"pnpm": "^8.12.1"
},
"devDependencies": {
"wireit": "0.14.3"
}
}

View File

@ -1,24 +0,0 @@
/**
* External dependencies
*/
import { addFilter } from '@wordpress/hooks';
/**
* Internal dependencies
*/
import './index.scss';
const MyExamplePage = () => <h1>My Example Extension</h1>;
addFilter( 'woocommerce_admin_pages_list', 'my-namespace', ( pages ) => {
pages.push( {
container: MyExamplePage,
path: '/example',
breadcrumbs: [ 'My Example Page' ],
navArgs: {
id: 'my-example-page',
},
} );
return pages;
} );

View File

@ -1 +0,0 @@
// Add styles here.