@wp-operations/wp-ide 0.3.0 → 0.4.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 +8 -41
- package/dist/index.js +16 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,55 +1,22 @@
|
|
|
1
1
|
# @wp-operations/wp-ide
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## The editor
|
|
3
|
+
A simple WordPress-first editor in your browser, with a live preview. It comes with [wp-ops](../wp-ops):
|
|
6
4
|
|
|
7
5
|
```bash
|
|
8
|
-
npm install -g @wp-operations/wp-
|
|
6
|
+
npm install -g @wp-operations/wp-ops
|
|
9
7
|
cd my-platform
|
|
10
8
|
wp-ide serve --preview=http://localhost:8080
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
It opens on `http://127.0.0.1:4500/#token
|
|
14
|
-
|
|
15
|
-
- a sidebar of apps grouped by kind, plus your plugins and the full repository;
|
|
16
|
-
- a file tree and editor (Ctrl/Cmd+S saves) with the git branch and a list of changes;
|
|
17
|
-
- a live preview of the selected app from a running `wp-ops sandbox` (`--preview`).
|
|
18
|
-
|
|
19
|
-
It listens on 127.0.0.1 only, checks the Host header, and every API call needs the token from the printed URL. It never reads or writes `.git/`, `vendor/`, `node_modules/` or `.local/`, refuses paths outside the repository (including through links), and limits files to 400 KB.
|
|
20
|
-
|
|
21
|
-
## The platform repository contract
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
platform.json the platform's own config (copied from the theme)
|
|
25
|
-
.github/platform.json { platform, packages, apps: { <kind>: { label, folder, manifest } } }
|
|
26
|
-
.github/<kind>.json { "<slug>": { "server", "app_path", "theme_slug" } }
|
|
27
|
-
.github/workflows/composer.yml
|
|
28
|
-
packages/<vendor>/<name>/ plugins: composer.json "type": "psr4-plugin"
|
|
29
|
-
<kind folder>/<slug>/ apps: composer.json "type": "wp-app"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
In `.github/platform.json`, `folder` defaults to the kind's key and `manifest` defaults to `.github/<key>.json`. Names are normalized exactly as the theme does it.
|
|
33
|
-
|
|
34
|
-
## API
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
import {
|
|
38
|
-
readLayout, hasLayout, layoutJson, findKind, // .github/platform.json
|
|
39
|
-
readManifest, writeManifest, // .github/<kind>.json
|
|
40
|
-
listApps, listPlugins, // apps and plugins, with warnings
|
|
41
|
-
editComposer, encodeJson, relativePath, // byte-identical to the theme's composer.json edits
|
|
42
|
-
slug, folder, // the theme's name normalization
|
|
43
|
-
startEditor, safePath, // the editor server
|
|
44
|
-
resolveProject, useLocalData, appServerOptions, runBlueprint, // .local convention, wp-app helpers
|
|
45
|
-
} from '@wp-operations/wp-ide';
|
|
46
|
-
```
|
|
11
|
+
It opens on `http://127.0.0.1:4500/#token=…` with:
|
|
47
12
|
|
|
48
|
-
|
|
13
|
+
- your apps, plugins and the whole repository in the sidebar;
|
|
14
|
+
- a file tree and editor (Ctrl/Cmd+S saves), the git branch and the list of changes;
|
|
15
|
+
- a live preview of the selected app from `wp-ops sandbox` (`--preview`).
|
|
49
16
|
|
|
50
|
-
|
|
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.
|
|
51
18
|
|
|
52
|
-
|
|
19
|
+
wp-ops and wp-code also use it as a library: it reads the platform repository (`.github/app.json`, the app manifests, apps and plugins) and makes the same composer.json edits the platform makes.
|
|
53
20
|
|
|
54
21
|
## License
|
|
55
22
|
|
package/dist/index.js
CHANGED
|
@@ -137,22 +137,18 @@ 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/
|
|
140
|
+
var LAYOUT_FILE = ".github/app.json";
|
|
141
|
+
var LEGACY_LAYOUT_FILE = ".github/platform.json";
|
|
142
|
+
var RESERVED_KINDS = ["app"];
|
|
141
143
|
var PLUGIN_TYPE = "psr4-plugin";
|
|
142
144
|
var APP_TYPE = "wp-app";
|
|
143
145
|
var COMPOSER_ACTIONS = ["add", "remove", "update"];
|
|
144
146
|
var DEFAULT_KINDS = [
|
|
145
147
|
{
|
|
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"
|
|
148
|
+
key: "apps",
|
|
149
|
+
label: "Apps",
|
|
150
|
+
folder: "apps",
|
|
151
|
+
manifest: ".github/apps.json"
|
|
156
152
|
}
|
|
157
153
|
];
|
|
158
154
|
function slug(value) {
|
|
@@ -209,11 +205,14 @@ function normalizeLayout(data) {
|
|
|
209
205
|
kinds
|
|
210
206
|
};
|
|
211
207
|
}
|
|
208
|
+
function layoutFile(rootDir) {
|
|
209
|
+
return fs3.existsSync(path4.join(rootDir, LAYOUT_FILE)) || !fs3.existsSync(path4.join(rootDir, LEGACY_LAYOUT_FILE)) ? LAYOUT_FILE : LEGACY_LAYOUT_FILE;
|
|
210
|
+
}
|
|
212
211
|
function hasLayout(rootDir) {
|
|
213
|
-
return fs3.existsSync(path4.join(rootDir,
|
|
212
|
+
return fs3.existsSync(path4.join(rootDir, layoutFile(rootDir)));
|
|
214
213
|
}
|
|
215
214
|
function readLayout(rootDir) {
|
|
216
|
-
const data = readJson(path4.join(rootDir,
|
|
215
|
+
const data = readJson(path4.join(rootDir, layoutFile(rootDir)));
|
|
217
216
|
if (data === null) {
|
|
218
217
|
throw new Error(
|
|
219
218
|
`${LAYOUT_FILE} was not found in ${rootDir}. Run "wp-ops init" first.`
|
|
@@ -468,7 +467,7 @@ iframe { width:100%; height:100%; border:0; background:#fff; }
|
|
|
468
467
|
nav.appendChild(item(p.name, p.version, p.warnings.join('; '), function () { open({ dir: p.path }); }));
|
|
469
468
|
});
|
|
470
469
|
} else {
|
|
471
|
-
nav.appendChild(el('div', 'empty', 'No .github/
|
|
470
|
+
nav.appendChild(el('div', 'empty', 'No .github/app.json here. Run "wp-ops init" to make this a platform repository.'));
|
|
472
471
|
}
|
|
473
472
|
nav.appendChild(el('h4', '', 'Repository'));
|
|
474
473
|
nav.appendChild(item('All files', '', '', function () { open({ dir: '' }); }));
|
|
@@ -793,10 +792,12 @@ export {
|
|
|
793
792
|
CONFIG_FILENAME,
|
|
794
793
|
DEFAULT_KINDS,
|
|
795
794
|
LAYOUT_FILE,
|
|
795
|
+
LEGACY_LAYOUT_FILE,
|
|
796
796
|
LOCAL_DIR,
|
|
797
797
|
MAX_FILE_BYTES,
|
|
798
798
|
PACKAGE_NAME,
|
|
799
799
|
PLUGIN_TYPE,
|
|
800
|
+
RESERVED_KINDS,
|
|
800
801
|
ROOT_MARKERS,
|
|
801
802
|
appServerOptions,
|
|
802
803
|
editComposer,
|
|
@@ -806,6 +807,7 @@ export {
|
|
|
806
807
|
findRootDir,
|
|
807
808
|
folder,
|
|
808
809
|
hasLayout,
|
|
810
|
+
layoutFile,
|
|
809
811
|
layoutJson,
|
|
810
812
|
listApps,
|
|
811
813
|
listPlugins,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-operations/wp-ide",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "A simple WordPress-first browser editor with live preview, and the platform repository 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": {
|