@wp-operations/wp-ide 0.3.1 → 0.5.0
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 +1 -1
- package/cli.js +1 -1
- package/dist/index.js +20 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ It opens on `http://127.0.0.1:4500/#token=…` with:
|
|
|
16
16
|
|
|
17
17
|
It listens on 127.0.0.1 only, and every request needs the token from the printed URL. It never touches `.git/`, `vendor/`, `node_modules/` or `.local/`, stays inside the repository, and limits files to 400 KB.
|
|
18
18
|
|
|
19
|
-
wp-ops and wp-code also use it as a library: it reads the
|
|
19
|
+
wp-ops and wp-code also use it as a library: it reads the WP monorepo (`.github/app.json`, the app manifests, apps and plugins) and makes the same composer.json edits the platform makes.
|
|
20
20
|
|
|
21
21
|
## License
|
|
22
22
|
|
package/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ const HELP = `wp-ide v${version}
|
|
|
12
12
|
Usage:
|
|
13
13
|
wp-ide serve [dir] [--port=4500] [--preview=<sandbox url>]
|
|
14
14
|
|
|
15
|
-
Opens a local editor for the
|
|
15
|
+
Opens a local editor for the WP monorepo, or any folder, that contains [dir]
|
|
16
16
|
(default: the current folder). It only listens on 127.0.0.1 and every
|
|
17
17
|
request needs the token from the printed URL.
|
|
18
18
|
|
package/dist/index.js
CHANGED
|
@@ -137,22 +137,19 @@ async function runBlueprint(php, blueprint) {
|
|
|
137
137
|
// src/platform.ts
|
|
138
138
|
import fs3 from "fs";
|
|
139
139
|
import path4 from "path";
|
|
140
|
-
var LAYOUT_FILE = ".github/
|
|
141
|
-
var
|
|
140
|
+
var LAYOUT_FILE = ".github/app.json";
|
|
141
|
+
var LEGACY_LAYOUT_FILE = ".github/platform.json";
|
|
142
|
+
var RESERVED_KINDS = ["app"];
|
|
143
|
+
var PLUGIN_TYPE = "plugin";
|
|
144
|
+
var PLUGIN_TYPES = ["plugin", "psr4-plugin"];
|
|
142
145
|
var APP_TYPE = "wp-app";
|
|
143
146
|
var COMPOSER_ACTIONS = ["add", "remove", "update"];
|
|
144
147
|
var DEFAULT_KINDS = [
|
|
145
148
|
{
|
|
146
|
-
key: "
|
|
147
|
-
label: "
|
|
148
|
-
folder: "
|
|
149
|
-
manifest: ".github/
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
key: "homepages",
|
|
153
|
-
label: "Homepages",
|
|
154
|
-
folder: "homepages",
|
|
155
|
-
manifest: ".github/homepages.json"
|
|
149
|
+
key: "apps",
|
|
150
|
+
label: "Apps",
|
|
151
|
+
folder: "apps",
|
|
152
|
+
manifest: ".github/apps.json"
|
|
156
153
|
}
|
|
157
154
|
];
|
|
158
155
|
function slug(value) {
|
|
@@ -209,11 +206,14 @@ function normalizeLayout(data) {
|
|
|
209
206
|
kinds
|
|
210
207
|
};
|
|
211
208
|
}
|
|
209
|
+
function layoutFile(rootDir) {
|
|
210
|
+
return fs3.existsSync(path4.join(rootDir, LAYOUT_FILE)) || !fs3.existsSync(path4.join(rootDir, LEGACY_LAYOUT_FILE)) ? LAYOUT_FILE : LEGACY_LAYOUT_FILE;
|
|
211
|
+
}
|
|
212
212
|
function hasLayout(rootDir) {
|
|
213
|
-
return fs3.existsSync(path4.join(rootDir,
|
|
213
|
+
return fs3.existsSync(path4.join(rootDir, layoutFile(rootDir)));
|
|
214
214
|
}
|
|
215
215
|
function readLayout(rootDir) {
|
|
216
|
-
const data = readJson(path4.join(rootDir,
|
|
216
|
+
const data = readJson(path4.join(rootDir, layoutFile(rootDir)));
|
|
217
217
|
if (data === null) {
|
|
218
218
|
throw new Error(
|
|
219
219
|
`${LAYOUT_FILE} was not found in ${rootDir}. Run "wp-ops init" first.`
|
|
@@ -312,7 +312,7 @@ function listPlugins(rootDir, layout = readLayout(rootDir)) {
|
|
|
312
312
|
path: path4.relative(rootDir, child).split(path4.sep).join("/"),
|
|
313
313
|
dir: child,
|
|
314
314
|
namespace: Object.keys(data.autoload?.["psr-4"] ?? {})[0] ?? "",
|
|
315
|
-
warnings: type
|
|
315
|
+
warnings: PLUGIN_TYPES.includes(type) ? [] : [`type is "${type}", expected "${PLUGIN_TYPE}"`]
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
if (depth < 2) {
|
|
@@ -468,7 +468,7 @@ iframe { width:100%; height:100%; border:0; background:#fff; }
|
|
|
468
468
|
nav.appendChild(item(p.name, p.version, p.warnings.join('; '), function () { open({ dir: p.path }); }));
|
|
469
469
|
});
|
|
470
470
|
} else {
|
|
471
|
-
nav.appendChild(el('div', 'empty', 'No .github/
|
|
471
|
+
nav.appendChild(el('div', 'empty', 'No .github/app.json here. Run "wp-ops init" to make this a WP monorepo.'));
|
|
472
472
|
}
|
|
473
473
|
nav.appendChild(el('h4', '', 'Repository'));
|
|
474
474
|
nav.appendChild(item('All files', '', '', function () { open({ dir: '' }); }));
|
|
@@ -793,10 +793,13 @@ export {
|
|
|
793
793
|
CONFIG_FILENAME,
|
|
794
794
|
DEFAULT_KINDS,
|
|
795
795
|
LAYOUT_FILE,
|
|
796
|
+
LEGACY_LAYOUT_FILE,
|
|
796
797
|
LOCAL_DIR,
|
|
797
798
|
MAX_FILE_BYTES,
|
|
798
799
|
PACKAGE_NAME,
|
|
799
800
|
PLUGIN_TYPE,
|
|
801
|
+
PLUGIN_TYPES,
|
|
802
|
+
RESERVED_KINDS,
|
|
800
803
|
ROOT_MARKERS,
|
|
801
804
|
appServerOptions,
|
|
802
805
|
editComposer,
|
|
@@ -806,6 +809,7 @@ export {
|
|
|
806
809
|
findRootDir,
|
|
807
810
|
folder,
|
|
808
811
|
hasLayout,
|
|
812
|
+
layoutFile,
|
|
809
813
|
layoutJson,
|
|
810
814
|
listApps,
|
|
811
815
|
listPlugins,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-operations/wp-ide",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A simple WordPress-first browser editor with live preview, and the
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "A simple WordPress-first browser editor with live preview, and the WP monorepo library used by wp-ops and wp-code. Comes with @wp-operations/wp-ops.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|