@storepress/create-plugin-html 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/index.js +73 -10
- package/package.json +1 -1
- package/plugin-templates/eslint.config.js.mustache +133 -0
- package/plugin-templates/index.html.mustache +1 -1
- package/plugin-templates/src/interactive/index.js.mustache +4 -1
- package/plugin-templates/src/react/index.js.mustache +3 -0
- package/plugin-templates/tools/changelog.js.mustache +40 -41
- package/plugin-templates/tools/package.js.mustache +47 -39
- package/plugin-templates/tools/packages-install.js.mustache +0 -2
- package/plugin-templates/tools/webpack.config.externals.js.mustache +0 -1
- package/plugin-templates/webpack.config.js.mustache +0 -1
- package/plugin-templates/.eslintrc.js.mustache +0 -197
- package/plugin-templates/.github/workflows/deploy-github-pages.yaml.mustache +0 -52
- package/plugin-templates/.github/workflows/release.yaml.mustache +0 -72
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@ This is a template for [`@wordpress/create-block`](https://developer.wordpress.o
|
|
|
7
7
|
This template can be used by running the following command:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npx -y @wordpress/create-block@latest --template @storepress/create-plugin-html
|
|
10
|
+
npx -y @wordpress/create-block@latest --template @storepress/create-plugin-html my-html-extension-name && cd "$_"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Navigate to the newly created folder and get started.
|
|
14
14
|
|
|
15
15
|
```
|
|
16
|
-
npm i
|
|
17
|
-
npm run build
|
|
18
|
-
npx -y http-server
|
|
16
|
+
npm i # Install dependencies and Update package dependency
|
|
17
|
+
npm run build # Build the javascript
|
|
18
|
+
npx -y http-server # Start Server
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Development
|
|
@@ -23,7 +23,7 @@ npx -y http-server # Start Server
|
|
|
23
23
|
For development on this tool itself, you can also install from a local directory.
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
npx -y @wordpress/create-block@latest --template ./
|
|
26
|
+
npx -y @wordpress/create-block@latest --template ./create-plugin-html my-html-extension-name && cd "$_"
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### Add Tests
|
package/index.js
CHANGED
|
@@ -3,27 +3,87 @@
|
|
|
3
3
|
*/
|
|
4
4
|
const {join} = require('path')
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Converts a string to kebab-case by replacing separators (hyphens, dots,
|
|
8
|
+
* underscores, spaces, and plus signs) with hyphens and lowercasing.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} input - The string to convert.
|
|
11
|
+
* @returns {string} The kebab-cased string (e.g. "my-plugin-name").
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* kebabCase('My Plugin Name') // => 'my-plugin-name'
|
|
15
|
+
* kebabCase('my_plugin.name') // => 'my-plugin-name'
|
|
16
|
+
*/
|
|
7
17
|
function kebabCase(input) {
|
|
8
18
|
const regex = /[-._\s+]/gi
|
|
9
19
|
return input.replace(regex, '-').toLowerCase()
|
|
10
20
|
}
|
|
11
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Converts a string to snake_case by replacing separators (hyphens, dots,
|
|
24
|
+
* underscores, spaces, and plus signs) with underscores and lowercasing.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} input - The string to convert.
|
|
27
|
+
* @returns {string} The snake_cased string (e.g. "my_plugin_name").
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* snakeCase('My Plugin Name') // => 'my_plugin_name'
|
|
31
|
+
* snakeCase('my-plugin.name') // => 'my_plugin_name'
|
|
32
|
+
*/
|
|
33
|
+
function snakeCase(input) {
|
|
34
|
+
const regex = /[-._\s+]/gi
|
|
35
|
+
return input.replace(regex, '_').toLowerCase()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts a string to CONSTANT_CASE by replacing separators (hyphens, dots,
|
|
40
|
+
* underscores, spaces, and plus signs) with underscores and uppercasing.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} input - The string to convert.
|
|
43
|
+
* @returns {string} The constant-cased string (e.g. "MY_PLUGIN_NAME").
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* constantCase('my-plugin-name') // => 'MY_PLUGIN_NAME'
|
|
47
|
+
* constantCase('my plugin.name') // => 'MY_PLUGIN_NAME'
|
|
48
|
+
*/
|
|
12
49
|
function constantCase(input) {
|
|
13
50
|
const regex = /[-._\s+]/gi
|
|
14
51
|
return input.replace(regex, '_').toUpperCase()
|
|
15
52
|
}
|
|
16
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Maps the literal string `"storepress"` to its branded casing `"StorePress"`,
|
|
56
|
+
* leaving all other inputs unchanged.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} input - The string to check.
|
|
59
|
+
* @returns {string} `"StorePress"` if input is `"storepress"`, otherwise the original input.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* pascalStorePress('storepress') // => 'StorePress'
|
|
63
|
+
* pascalStorePress('myplugin') // => 'myplugin'
|
|
64
|
+
*/
|
|
17
65
|
function pascalStorePress(input) {
|
|
18
66
|
return 'storepress' === input ? 'StorePress' : input
|
|
19
67
|
}
|
|
20
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Converts a string to PascalCase by extracting alphanumeric words and
|
|
71
|
+
* capitalizing the first letter of each.
|
|
72
|
+
*
|
|
73
|
+
* @param {string} input - The string to convert.
|
|
74
|
+
* @returns {string} The PascalCased string (e.g. "MyPluginName").
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* pascalCase('my-plugin-name') // => 'MyPluginName'
|
|
78
|
+
* pascalCase('my plugin name') // => 'MyPluginName'
|
|
79
|
+
*/
|
|
21
80
|
function pascalCase(input) {
|
|
22
81
|
return (input.match(/[a-zA-Z0-9]+/g) || []).map(w => `${w.charAt(0).toUpperCase()}${w.slice(1)}`).join('')
|
|
23
82
|
}
|
|
24
83
|
|
|
25
84
|
module.exports = {
|
|
26
85
|
defaultValues : {
|
|
86
|
+
wpScripts : false,
|
|
27
87
|
folderName : 'src',
|
|
28
88
|
namespace : 'storepress',
|
|
29
89
|
slug : 'plugin',
|
|
@@ -36,7 +96,7 @@ module.exports = {
|
|
|
36
96
|
attributes : {},
|
|
37
97
|
license : 'GPL-2.0-or-later',
|
|
38
98
|
customScripts : {
|
|
39
|
-
'postinstall' : 'git init -q && rimraf .husky && npx husky init && echo "npx lint-staged" > .husky/pre-commit',
|
|
99
|
+
'postinstall' : 'npm run packages-install:all && git init -q && rimraf .husky && npx husky init && echo "npx lint-staged" > .husky/pre-commit',
|
|
40
100
|
|
|
41
101
|
'prebuild' : 'rimraf build && npm run external:build',
|
|
42
102
|
'build' : 'wp-scripts build --webpack-copy-php --experimental-modules',
|
|
@@ -73,11 +133,11 @@ module.exports = {
|
|
|
73
133
|
'test:e2e' : 'wp-scripts test-e2e',
|
|
74
134
|
'test:unit' : 'wp-scripts test-unit-js',
|
|
75
135
|
|
|
76
|
-
"external:dev": "wp-scripts start --no-watch --config tools/webpack.config.externals.js --experimental-modules --webpack-no-externals",
|
|
77
|
-
"external:build": "wp-scripts build --config tools/webpack.config.externals.js --experimental-modules --webpack-no-externals",
|
|
136
|
+
"external:dev" : "wp-scripts start --no-watch --config tools/webpack.config.externals.js --experimental-modules --webpack-no-externals",
|
|
137
|
+
"external:build" : "wp-scripts build --config tools/webpack.config.externals.js --experimental-modules --webpack-no-externals",
|
|
78
138
|
|
|
79
139
|
'prestart' : 'rimraf build && npm run external:dev',
|
|
80
|
-
'start'
|
|
140
|
+
'start' : 'wp-scripts start --webpack-copy-php --experimental-modules',
|
|
81
141
|
},
|
|
82
142
|
npmDependencies : [
|
|
83
143
|
'@storepress/utils',
|
|
@@ -86,17 +146,16 @@ module.exports = {
|
|
|
86
146
|
],
|
|
87
147
|
npmDevDependencies : [
|
|
88
148
|
'@wordpress/scripts',
|
|
89
|
-
'@
|
|
90
|
-
'@
|
|
149
|
+
'@wordpress/dependency-extraction-webpack-plugin',
|
|
150
|
+
'@wordpress/eslint-plugin',
|
|
91
151
|
'@wordpress/base-styles',
|
|
92
152
|
'@wordpress/dependency-extraction-webpack-plugin',
|
|
93
|
-
'eslint-plugin-you-dont-need-lodash-underscore',
|
|
94
153
|
'husky',
|
|
95
154
|
'lint-staged',
|
|
96
|
-
"prettier
|
|
155
|
+
"prettier",
|
|
97
156
|
'fs-extra',
|
|
98
157
|
'webpack-remove-empty-scripts',
|
|
99
|
-
'eslint-plugin-prettier
|
|
158
|
+
'eslint-plugin-prettier',
|
|
100
159
|
'eslint-formatter-pretty',
|
|
101
160
|
'rimraf',
|
|
102
161
|
],
|
|
@@ -126,6 +185,8 @@ module.exports = {
|
|
|
126
185
|
const constantSlug = constantCase(view.slug) // TWO_WORDS
|
|
127
186
|
const kebabSlug = kebabCase(view.slug) // two-words
|
|
128
187
|
const pascaleSlug = pascalCase(pascalStorePress(view.slug)) // 'TwoWords'
|
|
188
|
+
const snakeNamespace = snakeCase(view.namespace)
|
|
189
|
+
const snakeSlug = snakeCase(view.slug)
|
|
129
190
|
return {
|
|
130
191
|
...view,
|
|
131
192
|
name : `@${kebabNamespace}/${kebabSlug}`,
|
|
@@ -133,10 +194,12 @@ module.exports = {
|
|
|
133
194
|
constantNamespace : constantNamespace,
|
|
134
195
|
kebabNamespace : kebabNamespace,
|
|
135
196
|
pascaleNamespace : pascaleNamespace,
|
|
197
|
+
snakeNamespace : snakeNamespace,
|
|
136
198
|
|
|
137
199
|
constantSlug : constantSlug,
|
|
138
200
|
kebabSlug : kebabSlug,
|
|
139
201
|
pascaleSlug : pascaleSlug,
|
|
202
|
+
snakeSlug : snakeSlug,
|
|
140
203
|
|
|
141
204
|
GITHUB_REPOSITORY_NAME : '${{ github.event.repository.name }}',
|
|
142
205
|
GITHUB_RELEASE_NAME : '${{ env.RELEASE_NAME }}',
|
package/package.json
CHANGED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
const wordpress = require('@wordpress/eslint-plugin');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
const { getWebPackAlias } = require('./tools/webpack-helpers');
|
|
10
|
+
const aliases = Object.keys(getWebPackAlias());
|
|
11
|
+
|
|
12
|
+
// All @wordpress/* packages that get externalized to wp.* globals at build time.
|
|
13
|
+
// These don't need to be in package.json — WordPress provides them at runtime.
|
|
14
|
+
// https://developer.wordpress.org/block-editor/reference-guides/packages/packages-eslint-plugin/
|
|
15
|
+
const wordPressPackages = [
|
|
16
|
+
'@wordpress/a11y',
|
|
17
|
+
'@wordpress/annotations',
|
|
18
|
+
'@wordpress/api-fetch',
|
|
19
|
+
'@wordpress/autop',
|
|
20
|
+
'@wordpress/blob',
|
|
21
|
+
'@wordpress/block-directory',
|
|
22
|
+
'@wordpress/block-editor',
|
|
23
|
+
'@wordpress/block-library',
|
|
24
|
+
'@wordpress/block-serialization-default-parser',
|
|
25
|
+
'@wordpress/blocks',
|
|
26
|
+
'@wordpress/commands',
|
|
27
|
+
'@wordpress/components',
|
|
28
|
+
'@wordpress/compose',
|
|
29
|
+
'@wordpress/core-commands',
|
|
30
|
+
'@wordpress/core-data',
|
|
31
|
+
'@wordpress/customize-widgets',
|
|
32
|
+
'@wordpress/data',
|
|
33
|
+
'@wordpress/data-controls',
|
|
34
|
+
'@wordpress/date',
|
|
35
|
+
'@wordpress/deprecated',
|
|
36
|
+
'@wordpress/dom',
|
|
37
|
+
'@wordpress/dom-ready',
|
|
38
|
+
'@wordpress/edit-post',
|
|
39
|
+
'@wordpress/edit-site',
|
|
40
|
+
'@wordpress/edit-widgets',
|
|
41
|
+
'@wordpress/editor',
|
|
42
|
+
'@wordpress/element',
|
|
43
|
+
'@wordpress/escape-html',
|
|
44
|
+
'@wordpress/format-library',
|
|
45
|
+
'@wordpress/hooks',
|
|
46
|
+
'@wordpress/html-entities',
|
|
47
|
+
'@wordpress/i18n',
|
|
48
|
+
'@wordpress/icons',
|
|
49
|
+
'@wordpress/interactivity',
|
|
50
|
+
'@wordpress/interactivity-router',
|
|
51
|
+
'@wordpress/interface',
|
|
52
|
+
'@wordpress/is-shallow-equal',
|
|
53
|
+
'@wordpress/keyboard-shortcuts',
|
|
54
|
+
'@wordpress/keycodes',
|
|
55
|
+
'@wordpress/list-reusable-blocks',
|
|
56
|
+
'@wordpress/media-utils',
|
|
57
|
+
'@wordpress/notices',
|
|
58
|
+
'@wordpress/nux',
|
|
59
|
+
'@wordpress/patterns',
|
|
60
|
+
'@wordpress/plugins',
|
|
61
|
+
'@wordpress/preferences',
|
|
62
|
+
'@wordpress/preferences-persistence',
|
|
63
|
+
'@wordpress/primitives',
|
|
64
|
+
'@wordpress/priority-queue',
|
|
65
|
+
'@wordpress/private-apis',
|
|
66
|
+
'@wordpress/redux-routine',
|
|
67
|
+
'@wordpress/reusable-blocks',
|
|
68
|
+
'@wordpress/rich-text',
|
|
69
|
+
'@wordpress/router',
|
|
70
|
+
'@wordpress/server-side-render',
|
|
71
|
+
'@wordpress/shortcode',
|
|
72
|
+
'@wordpress/style-engine',
|
|
73
|
+
'@wordpress/token-list',
|
|
74
|
+
'@wordpress/url',
|
|
75
|
+
'@wordpress/viewport',
|
|
76
|
+
'@wordpress/warning',
|
|
77
|
+
'@wordpress/widgets',
|
|
78
|
+
'@wordpress/wordcount',
|
|
79
|
+
'@storepress/html-plugin',
|
|
80
|
+
'adm-zip',
|
|
81
|
+
'fast-glob',
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
const restrictedImports = [
|
|
85
|
+
{
|
|
86
|
+
name: 'lodash',
|
|
87
|
+
message:
|
|
88
|
+
'This Lodash method is not recommended. Please use native functionality instead. If using `memoize`, please use `memize` instead.',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'classnames',
|
|
92
|
+
message:
|
|
93
|
+
"Please use `clsx` instead. It's a lighter and faster drop-in replacement for `classnames`.",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'redux',
|
|
97
|
+
importNames: ['combineReducers'],
|
|
98
|
+
message: 'Please use `combineReducers` from `@wordpress/data` instead.',
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
module.exports = [
|
|
103
|
+
{
|
|
104
|
+
ignores: ['build/', 'vendor/', 'node_modules/'],
|
|
105
|
+
},
|
|
106
|
+
...wordpress.configs.recommended,
|
|
107
|
+
{
|
|
108
|
+
languageOptions: {
|
|
109
|
+
globals: {
|
|
110
|
+
StorePress: 'writable',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
settings: {
|
|
114
|
+
'import/core-modules': [...wordPressPackages, ...aliases],
|
|
115
|
+
'import/resolver': {
|
|
116
|
+
node: {
|
|
117
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
rules: {
|
|
122
|
+
'@wordpress/dependency-group': 'warn',
|
|
123
|
+
'no-unused-vars': 'warn',
|
|
124
|
+
'@wordpress/no-unsafe-wp-apis': 'warn',
|
|
125
|
+
'no-restricted-imports': [
|
|
126
|
+
'error',
|
|
127
|
+
{
|
|
128
|
+
paths: restrictedImports,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
];
|
|
@@ -1,60 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
"use strict";
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
const fs = require(
|
|
7
|
-
const { stdout } = require('process')
|
|
6
|
+
const fs = require("fs");
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* WordPress dependencies
|
|
11
10
|
*/
|
|
11
|
+
const { getPackageProp, fromProjectRoot } = require("@wordpress/scripts/utils");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
fromProjectRoot,
|
|
16
|
-
} = require('@wordpress/scripts/utils')
|
|
13
|
+
// Get Current Version.
|
|
14
|
+
const version = getPackageProp("version");
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
// Get Changelog File.
|
|
17
|
+
const changelogFile = fromProjectRoot("changelog.txt");
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
// Read and find the changelog entry for the current version.
|
|
20
|
+
const changelogContent = fs.readFileSync(changelogFile, "utf8");
|
|
21
|
+
const lines = changelogContent.split("\n");
|
|
22
|
+
const changelogEntry = [];
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
24
|
+
const commonPattern = `^(?:\\d{4}-\\d{2}-\\d{2}|\\d{2}-\\d{2}-\\d{4})\\s*-\\s*version`;
|
|
25
|
+
const currentPattern = `${commonPattern}\\s*${version}`;
|
|
26
|
+
|
|
27
|
+
const currentExp = new RegExp(currentPattern, "i");
|
|
28
|
+
|
|
29
|
+
const sectionExp = new RegExp(commonPattern, "i");
|
|
30
|
+
|
|
31
|
+
let inSection = false;
|
|
29
32
|
|
|
30
33
|
for (const line of lines) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
// Reach current section.
|
|
35
|
+
if (currentExp.test(line)) {
|
|
36
|
+
inSection = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// We have to stop when we get another section.
|
|
41
|
+
if (inSection) {
|
|
42
|
+
if (sectionExp.test(line)) {
|
|
43
|
+
inSection = false;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
changelogEntry.push(line);
|
|
48
|
+
}
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
if (changelogEntry.length === 0) {
|
|
44
|
-
|
|
52
|
+
changelogEntry.push(`- No changelog entry for version ${version}.\n\n`);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
//
|
|
48
|
-
const finalOutput = changelogEntry.join(
|
|
49
|
-
|
|
50
|
-
// 4. Check if running in GitHub Actions environment
|
|
51
|
-
/*if (process.env.GITHUB_OUTPUT) {
|
|
52
|
-
// If yes, write to the GITHUB_OUTPUT file to set an output variable
|
|
53
|
-
// The format `key<<DELIMITER` is used for multiline strings
|
|
54
|
-
fs.appendFileSync(process.env.GITHUB_OUTPUT, `changelog_body<<EOF\n${finalOutput}\nEOF\n`)
|
|
55
|
-
} else {
|
|
56
|
-
stdout.write(`${finalOutput}\n`)
|
|
57
|
-
}*/
|
|
55
|
+
// Prepare the final output string
|
|
56
|
+
const finalOutput = changelogEntry.join("\n").trim();
|
|
58
57
|
|
|
59
|
-
stdout.write(`## What's Changed\n\n`)
|
|
60
|
-
stdout.write(`${finalOutput}\n`)
|
|
58
|
+
process.stdout.write(`## What's Changed\n\n`);
|
|
59
|
+
process.stdout.write(`${finalOutput}\n`);
|
|
@@ -3,49 +3,50 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
const AdmZip = require('adm-zip');
|
|
7
|
-
const { sync: glob } = require('fast-glob');
|
|
8
|
-
const { dirname } = require('path');
|
|
9
|
-
const { stdout } = require('process');
|
|
10
|
-
const fs = require('fs-extra');
|
|
6
|
+
const AdmZip = require( 'adm-zip' );
|
|
7
|
+
const { sync: glob } = require( 'fast-glob' );
|
|
8
|
+
const { dirname, join } = require( 'path' );
|
|
9
|
+
const { stdout } = require( 'process' );
|
|
10
|
+
const fs = require( 'fs-extra' );
|
|
11
|
+
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* WordPress dependencies
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
const {
|
|
16
16
|
hasPackageProp,
|
|
17
17
|
getPackageProp,
|
|
18
18
|
hasArgInCLI,
|
|
19
|
-
} = require('@wordpress/scripts/utils');
|
|
19
|
+
} = require( '@wordpress/scripts/utils' );
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const packageName = getPackageProp( 'name' );
|
|
22
|
+
const packageVersion = getPackageProp( 'version' );
|
|
23
23
|
|
|
24
|
-
stdout.write(`Creating package for \`${
|
|
24
|
+
stdout.write( `Creating package for \`${ packageName }\` plugin... 🎁\n\n` );
|
|
25
25
|
const zip = new AdmZip();
|
|
26
|
-
const isZip = hasArgInCLI('--zip');
|
|
26
|
+
const isZip = hasArgInCLI( '--zip' );
|
|
27
27
|
|
|
28
28
|
let files = [];
|
|
29
29
|
|
|
30
|
-
if (hasPackageProp('
|
|
30
|
+
if ( hasPackageProp( 'files' ) ) {
|
|
31
31
|
stdout.write(
|
|
32
32
|
'Using the `files` field from `package.json` to detect files:\n\n'
|
|
33
33
|
);
|
|
34
34
|
|
|
35
|
-
files = glob(getPackageProp('
|
|
35
|
+
files = glob( getPackageProp( 'files' ), {
|
|
36
36
|
caseSensitiveMatch: false,
|
|
37
|
-
});
|
|
37
|
+
} );
|
|
38
38
|
} else {
|
|
39
|
-
stdout.write(
|
|
39
|
+
stdout.write(
|
|
40
|
+
'Using Plugin Handbook best practices to discover files:\n\n'
|
|
41
|
+
);
|
|
40
42
|
// See https://developer.wordpress.org/plugins/plugin-basics/best-practices/#file-organization.
|
|
41
43
|
files = glob(
|
|
42
44
|
[
|
|
43
|
-
'admin/**',
|
|
44
45
|
'build/**',
|
|
45
46
|
'includes/**',
|
|
46
47
|
'languages/**',
|
|
47
|
-
'
|
|
48
|
-
`${
|
|
48
|
+
'templates/**',
|
|
49
|
+
`${ packageName }.php`,
|
|
49
50
|
'uninstall.php',
|
|
50
51
|
'block.json',
|
|
51
52
|
'changelog.*',
|
|
@@ -58,34 +59,41 @@ if (hasPackageProp('zip')) {
|
|
|
58
59
|
);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
if (isZip) {
|
|
62
|
+
if ( isZip ) {
|
|
62
63
|
stdout.write(
|
|
63
|
-
`Creating archive for \`${
|
|
64
|
+
`Creating archive for \`${ packageName }\` plugin... 🎁\n\n`
|
|
64
65
|
);
|
|
65
|
-
files.forEach((file) => {
|
|
66
|
-
stdout.write(` 🥳 Adding \`${file}\`.\n`);
|
|
67
|
-
const zipDirectory = dirname(file);
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
files.forEach( ( file ) => {
|
|
67
|
+
stdout.write( ` 🥳 Adding \`${ file }\`.\n` );
|
|
68
|
+
const zipDirectory = dirname( file );
|
|
69
|
+
// Prefix every entry with the slug folder
|
|
70
|
+
const targetDir =
|
|
71
|
+
zipDirectory !== '.'
|
|
72
|
+
? join( packageName, zipDirectory )
|
|
73
|
+
: packageName;
|
|
74
|
+
zip.addLocalFile( file, targetDir );
|
|
75
|
+
} );
|
|
70
76
|
|
|
71
|
-
zip.writeZip(`./${
|
|
72
|
-
stdout.write(
|
|
77
|
+
zip.writeZip( `./${ packageName }-v${ packageVersion }.zip` );
|
|
78
|
+
stdout.write(
|
|
79
|
+
`\nDone. \`${ packageName }-v${ packageVersion }.zip\` is ready! 🎉\n`
|
|
80
|
+
);
|
|
73
81
|
} else {
|
|
74
|
-
fs.remove(
|
|
75
|
-
fs.ensureDir(
|
|
82
|
+
fs.remove( packageName ).then( () => {
|
|
83
|
+
fs.ensureDir( packageName, () => {
|
|
76
84
|
stdout.write(
|
|
77
|
-
`Creating directory for \`${
|
|
85
|
+
`Creating directory for \`${ packageName }\` plugin... 🎁\n\n`
|
|
78
86
|
);
|
|
79
87
|
|
|
80
|
-
files.forEach((file) => {
|
|
81
|
-
const to = `${
|
|
82
|
-
stdout.write(` 🥳 Adding \`${file}\`.\n`);
|
|
83
|
-
fs.copy(file, to);
|
|
84
|
-
});
|
|
88
|
+
files.forEach( ( file ) => {
|
|
89
|
+
const to = `${ packageName }/${ file }`;
|
|
90
|
+
stdout.write( ` 🥳 Adding \`${ file }\`.\n` );
|
|
91
|
+
fs.copy( file, to );
|
|
92
|
+
} );
|
|
85
93
|
|
|
86
94
|
stdout.write(
|
|
87
|
-
`\n\nDone. \`${
|
|
95
|
+
`\n\nDone. \`${ packageName }\` directory is ready! 🎉\n`
|
|
88
96
|
);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
97
|
+
} );
|
|
98
|
+
} );
|
|
91
99
|
}
|
|
@@ -10,7 +10,6 @@ const {
|
|
|
10
10
|
getRootFile,
|
|
11
11
|
getWebPackAlias,
|
|
12
12
|
} = require('./webpack-helpers');
|
|
13
|
-
const WoocommerceDependencyExtractionWebpackPlugin = require('@woocommerce/dependency-extraction-webpack-plugin');
|
|
14
13
|
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
|
|
15
14
|
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
16
15
|
const webpack = require('webpack');
|
|
@@ -10,7 +10,6 @@ const {
|
|
|
10
10
|
getRootFile,
|
|
11
11
|
getWebPackAlias,
|
|
12
12
|
} = require('./tools/webpack-helpers');
|
|
13
|
-
const WoocommerceDependencyExtractionWebpackPlugin = require('@woocommerce/dependency-extraction-webpack-plugin');
|
|
14
13
|
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
|
|
15
14
|
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
16
15
|
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
const restrictedImports = [
|
|
2
|
-
{
|
|
3
|
-
name: 'lodash',
|
|
4
|
-
importNames: [
|
|
5
|
-
'camelCase',
|
|
6
|
-
'capitalize',
|
|
7
|
-
'castArray',
|
|
8
|
-
'chunk',
|
|
9
|
-
'clamp',
|
|
10
|
-
'clone',
|
|
11
|
-
'cloneDeep',
|
|
12
|
-
'compact',
|
|
13
|
-
'concat',
|
|
14
|
-
'countBy',
|
|
15
|
-
'debounce',
|
|
16
|
-
'deburr',
|
|
17
|
-
'defaults',
|
|
18
|
-
'defaultTo',
|
|
19
|
-
'delay',
|
|
20
|
-
'difference',
|
|
21
|
-
'differenceWith',
|
|
22
|
-
'dropRight',
|
|
23
|
-
'each',
|
|
24
|
-
'escape',
|
|
25
|
-
'escapeRegExp',
|
|
26
|
-
'every',
|
|
27
|
-
'extend',
|
|
28
|
-
'filter',
|
|
29
|
-
'find',
|
|
30
|
-
'findIndex',
|
|
31
|
-
'findKey',
|
|
32
|
-
'findLast',
|
|
33
|
-
'first',
|
|
34
|
-
'flatMap',
|
|
35
|
-
'flatten',
|
|
36
|
-
'flattenDeep',
|
|
37
|
-
'flow',
|
|
38
|
-
'flowRight',
|
|
39
|
-
'forEach',
|
|
40
|
-
'fromPairs',
|
|
41
|
-
'has',
|
|
42
|
-
'identity',
|
|
43
|
-
'includes',
|
|
44
|
-
'invoke',
|
|
45
|
-
'isArray',
|
|
46
|
-
'isBoolean',
|
|
47
|
-
'isEqual',
|
|
48
|
-
'isFinite',
|
|
49
|
-
'isFunction',
|
|
50
|
-
'isMatch',
|
|
51
|
-
'isNil',
|
|
52
|
-
'isNumber',
|
|
53
|
-
'isObject',
|
|
54
|
-
'isObjectLike',
|
|
55
|
-
'isPlainObject',
|
|
56
|
-
'isString',
|
|
57
|
-
'isUndefined',
|
|
58
|
-
'keyBy',
|
|
59
|
-
'keys',
|
|
60
|
-
'last',
|
|
61
|
-
'lowerCase',
|
|
62
|
-
'map',
|
|
63
|
-
'mapKeys',
|
|
64
|
-
'maxBy',
|
|
65
|
-
'memoize',
|
|
66
|
-
'merge',
|
|
67
|
-
'negate',
|
|
68
|
-
'noop',
|
|
69
|
-
'nth',
|
|
70
|
-
'omit',
|
|
71
|
-
'omitBy',
|
|
72
|
-
'once',
|
|
73
|
-
'orderby',
|
|
74
|
-
'overEvery',
|
|
75
|
-
'partial',
|
|
76
|
-
'partialRight',
|
|
77
|
-
'pick',
|
|
78
|
-
'pickBy',
|
|
79
|
-
'random',
|
|
80
|
-
'reduce',
|
|
81
|
-
'reject',
|
|
82
|
-
'repeat',
|
|
83
|
-
'reverse',
|
|
84
|
-
'setWith',
|
|
85
|
-
'size',
|
|
86
|
-
'snakeCase',
|
|
87
|
-
'some',
|
|
88
|
-
'sortBy',
|
|
89
|
-
'startCase',
|
|
90
|
-
'startsWith',
|
|
91
|
-
'stubFalse',
|
|
92
|
-
'stubTrue',
|
|
93
|
-
'sum',
|
|
94
|
-
'sumBy',
|
|
95
|
-
'take',
|
|
96
|
-
'throttle',
|
|
97
|
-
'times',
|
|
98
|
-
'toString',
|
|
99
|
-
'trim',
|
|
100
|
-
'truncate',
|
|
101
|
-
'unescape',
|
|
102
|
-
'unionBy',
|
|
103
|
-
'uniq',
|
|
104
|
-
'uniqBy',
|
|
105
|
-
'uniqueId',
|
|
106
|
-
'uniqWith',
|
|
107
|
-
'upperFirst',
|
|
108
|
-
'values',
|
|
109
|
-
'without',
|
|
110
|
-
'words',
|
|
111
|
-
'xor',
|
|
112
|
-
'zip',
|
|
113
|
-
],
|
|
114
|
-
message:
|
|
115
|
-
'This Lodash method is not recommended. Please use native functionality instead. If using `memoize`, please use `memize` instead.',
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: 'classnames',
|
|
119
|
-
message:
|
|
120
|
-
"Please use `clsx` instead. It's a lighter and faster drop-in replacement for `classnames`.",
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
module.exports = {
|
|
125
|
-
root: true,
|
|
126
|
-
extends: [
|
|
127
|
-
'plugin:@woocommerce/eslint-plugin/recommended',
|
|
128
|
-
'plugin:you-dont-need-lodash-underscore/compatible',
|
|
129
|
-
],
|
|
130
|
-
settings: {
|
|
131
|
-
// List of modules that are externals in our webpack config.
|
|
132
|
-
// This helps the `import/no-extraneous-dependencies` and
|
|
133
|
-
//`import/no-unresolved` rules account for them.
|
|
134
|
-
'import/core-modules': [
|
|
135
|
-
'@woocommerce/blocks-registry',
|
|
136
|
-
'@wordpress/is-shallow-equal',
|
|
137
|
-
'@woocommerce/block-data',
|
|
138
|
-
'@woocommerce/blocks-checkout',
|
|
139
|
-
'@woocommerce/price-format',
|
|
140
|
-
'@woocommerce/settings',
|
|
141
|
-
'@woocommerce/shared-context',
|
|
142
|
-
'@woocommerce/shared-hocs',
|
|
143
|
-
'@woocommerce/data',
|
|
144
|
-
'@wordpress/components',
|
|
145
|
-
'@wordpress/i18n',
|
|
146
|
-
'@wordpress/blocks',
|
|
147
|
-
'@wordpress/a11y',
|
|
148
|
-
'@wordpress/api-fetch',
|
|
149
|
-
'@wordpress/block-editor',
|
|
150
|
-
'@wordpress/compose',
|
|
151
|
-
'@wordpress/data',
|
|
152
|
-
'@wordpress/core-data',
|
|
153
|
-
'@wordpress/editor',
|
|
154
|
-
'@wordpress/escape-html',
|
|
155
|
-
'@wordpress/hooks',
|
|
156
|
-
'@wordpress/keycodes',
|
|
157
|
-
'@wordpress/url',
|
|
158
|
-
'@wordpress/element',
|
|
159
|
-
'@woocommerce/blocks-test-utils',
|
|
160
|
-
'@woocommerce/e2e-utils',
|
|
161
|
-
'lodash',
|
|
162
|
-
'jquery',
|
|
163
|
-
'@storepress/utils',
|
|
164
|
-
'@storepress/html-plugin', // See: getWebPackAlias() from tools/webpack-helpers.js
|
|
165
|
-
'@utils', // See: getWebPackAlias() from tools/webpack-helpers.js
|
|
166
|
-
],
|
|
167
|
-
'import/resolver': {
|
|
168
|
-
node: {},
|
|
169
|
-
webpack: {},
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
env: {
|
|
173
|
-
browser: true,
|
|
174
|
-
es6: true,
|
|
175
|
-
node: true,
|
|
176
|
-
},
|
|
177
|
-
globals: {
|
|
178
|
-
jQuery: 'readonly',
|
|
179
|
-
wp: true,
|
|
180
|
-
wpApiSettings: true,
|
|
181
|
-
wcSettings: true,
|
|
182
|
-
es6: true,
|
|
183
|
-
StorePress: true,
|
|
184
|
-
},
|
|
185
|
-
rules: {
|
|
186
|
-
'@woocommerce/dependency-group': 'off',
|
|
187
|
-
'@wordpress/no-unsafe-wp-apis': 'warn',
|
|
188
|
-
'react/react-in-jsx-scope': 'off',
|
|
189
|
-
'no-restricted-imports': [
|
|
190
|
-
'error',
|
|
191
|
-
{
|
|
192
|
-
paths: restrictedImports,
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
'@wordpress/no-global-active-element': 'warn'
|
|
196
|
-
},
|
|
197
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# Simple workflow for deploying static content to GitHub Pages
|
|
2
|
-
name: Deploy to Pages
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
# Runs on pushes targeting the default branch
|
|
6
|
-
push:
|
|
7
|
-
branches: [$default-branch]
|
|
8
|
-
|
|
9
|
-
# Allows you to run this workflow manually from the Actions tab
|
|
10
|
-
workflow_dispatch:
|
|
11
|
-
|
|
12
|
-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
13
|
-
permissions:
|
|
14
|
-
contents: read
|
|
15
|
-
pages: write
|
|
16
|
-
id-token: write
|
|
17
|
-
|
|
18
|
-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
19
|
-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
20
|
-
concurrency:
|
|
21
|
-
group: "pages"
|
|
22
|
-
cancel-in-progress: false
|
|
23
|
-
|
|
24
|
-
jobs:
|
|
25
|
-
# Single deploy job since we're just deploying
|
|
26
|
-
deploy:
|
|
27
|
-
environment:
|
|
28
|
-
name: github-pages
|
|
29
|
-
url: {{ GITHUB_PAGE_URL }}
|
|
30
|
-
runs-on: ubuntu-latest
|
|
31
|
-
steps:
|
|
32
|
-
- name: "Checkout"
|
|
33
|
-
uses: actions/checkout@v4
|
|
34
|
-
|
|
35
|
-
- name: "Setup Node"
|
|
36
|
-
uses: actions/setup-node@v4
|
|
37
|
-
with:
|
|
38
|
-
node-version: '20.x'
|
|
39
|
-
|
|
40
|
-
- name: "Install and Build"
|
|
41
|
-
run: |
|
|
42
|
-
npm install
|
|
43
|
-
npm run build
|
|
44
|
-
rm -rf node_modules
|
|
45
|
-
|
|
46
|
-
- name: "Upload Page Contents"
|
|
47
|
-
uses: actions/upload-pages-artifact@v3
|
|
48
|
-
with:
|
|
49
|
-
path: '.'
|
|
50
|
-
- name: "Deploy to GitHub Pages"
|
|
51
|
-
id: deployment
|
|
52
|
-
uses: actions/deploy-pages@v4
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
on:
|
|
2
|
-
push:
|
|
3
|
-
# Sequence of patterns matched against refs/tags
|
|
4
|
-
tags:
|
|
5
|
-
- '**' # Push events to matching i.e. 1.0, 20.15.10, including hierarchical tags like v1.0/beta
|
|
6
|
-
# Semver (https://semver.org/) release pattern.
|
|
7
|
-
# - '[0-9]+.[0-9]+.[0-9]+*'
|
|
8
|
-
|
|
9
|
-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
10
|
-
permissions: write-all
|
|
11
|
-
|
|
12
|
-
env:
|
|
13
|
-
REPOSITORY_NAME: {{ GITHUB_REPOSITORY_NAME }}
|
|
14
|
-
|
|
15
|
-
name: Release
|
|
16
|
-
|
|
17
|
-
jobs:
|
|
18
|
-
|
|
19
|
-
# Build distribution release.
|
|
20
|
-
#
|
|
21
|
-
# Performs the following steps:
|
|
22
|
-
# - Checks out the repository
|
|
23
|
-
# - Setup and Install Node.js
|
|
24
|
-
# - NPM Install
|
|
25
|
-
# - Make Zip
|
|
26
|
-
# - Get Release Version
|
|
27
|
-
# - Get Release Filename
|
|
28
|
-
# - Get Changelog
|
|
29
|
-
# - Make Release
|
|
30
|
-
|
|
31
|
-
build:
|
|
32
|
-
name: Release
|
|
33
|
-
runs-on: ubuntu-latest
|
|
34
|
-
steps:
|
|
35
|
-
- name: "Checks out the repository"
|
|
36
|
-
uses: actions/checkout@v4
|
|
37
|
-
|
|
38
|
-
- name: "Setup and Install Node.js"
|
|
39
|
-
uses: actions/setup-node@v4
|
|
40
|
-
with:
|
|
41
|
-
node-version: '20.x'
|
|
42
|
-
|
|
43
|
-
- name: "NPM Install"
|
|
44
|
-
run: npm install
|
|
45
|
-
|
|
46
|
-
- name: "Make Zip"
|
|
47
|
-
run: npm run plugin-zip --if-present
|
|
48
|
-
|
|
49
|
-
- name: "Get Release Version"
|
|
50
|
-
run: |
|
|
51
|
-
echo "RELEASE_TAG=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
|
|
52
|
-
|
|
53
|
-
- name: "Get Release Filename"
|
|
54
|
-
run: |
|
|
55
|
-
echo "RELEASE_NAME=$(node -p -e "require('./package.json').name")" >> $GITHUB_ENV
|
|
56
|
-
|
|
57
|
-
- name: "Get Changelog"
|
|
58
|
-
id: changelog
|
|
59
|
-
run: |
|
|
60
|
-
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
|
61
|
-
node ./tools/changelog.js >> $GITHUB_OUTPUT
|
|
62
|
-
echo "EOF" >> $GITHUB_OUTPUT
|
|
63
|
-
|
|
64
|
-
- name: "Make Release"
|
|
65
|
-
uses: softprops/action-gh-release@v2
|
|
66
|
-
with:
|
|
67
|
-
files: ./{{ GITHUB_RELEASE_NAME }}.zip
|
|
68
|
-
make_latest: true
|
|
69
|
-
name: Release - v{{ GITHUB_RELEASE_TAG }}
|
|
70
|
-
body: {{ GITHUB_CHANGELOG_CONTENT }}
|
|
71
|
-
env:
|
|
72
|
-
GITHUB_TOKEN: {{ GITHUB_TOKEN }}
|