wp-typia 0.20.5 → 0.21.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 +5 -0
- package/bin/argv-walker.d.ts +19 -0
- package/bin/argv-walker.js +53 -0
- package/bin/routing-metadata.generated.d.ts +1 -1
- package/bin/routing-metadata.generated.js +38 -38
- package/bin/wp-typia.js +75 -87
- package/dist-bunli/.bunli/commands.gen.js +4898 -1244
- package/dist-bunli/{cli-xnh2s5kz.js → cli-9x01fjna.js} +346 -41
- package/dist-bunli/{cli-add-6byyahb8.js → cli-add-93945fc2.js} +1899 -384
- package/dist-bunli/{cli-diagnostics-zecc6w1f.js → cli-diagnostics-5dvztm7q.js} +8 -2
- package/dist-bunli/{cli-doctor-2bc4sq7v.js → cli-doctor-zsndr5sw.js} +492 -20
- package/dist-bunli/{cli-3w3qxq9w.js → cli-hx88xwr4.js} +257 -25
- package/dist-bunli/cli-init-6xxc0snz.js +844 -0
- package/dist-bunli/{cli-2rev5hqm.js → cli-jfj54qej.js} +1 -1
- package/dist-bunli/{cli-xxzpb58s.js → cli-p95wr1q8.js} +72 -4
- package/dist-bunli/{cli-j1tyw390.js → cli-pav309dt.js} +670 -97
- package/dist-bunli/{cli-scaffold-19gyvxxt.js → cli-scaffold-d2vtf740.js} +6 -5
- package/dist-bunli/{cli-tesygdnr.js → cli-syg9qpxw.js} +22 -1
- package/dist-bunli/cli.js +31 -117
- package/dist-bunli/{command-list-pztcgga5.js → command-list-p452y8td.js} +561 -319
- package/dist-bunli/{migrations-1p6mbkyw.js → migrations-aj1rv3h8.js} +2 -2
- package/dist-bunli/node-cli.js +1035 -555
- package/package.json +5 -3
- package/dist-bunli/cli-init-gdyp9enw.js +0 -341
package/README.md
CHANGED
|
@@ -13,10 +13,15 @@ Use this package for new projects:
|
|
|
13
13
|
Extend an existing workspace with:
|
|
14
14
|
|
|
15
15
|
- `wp-typia add block counter-card --template basic`
|
|
16
|
+
- `wp-typia add style callout-emphasis --block counter-card`
|
|
17
|
+
- `wp-typia add transform quote-to-counter --from core/quote --to counter-card`
|
|
16
18
|
- `wp-typia add binding-source hero-data`
|
|
19
|
+
- `wp-typia add binding-source hero-data --block counter-card --attribute headline`
|
|
17
20
|
- `wp-typia add rest-resource snapshots --namespace my-plugin/v1 --methods list,read,create`
|
|
18
21
|
- `wp-typia add ability review-workflow`
|
|
19
22
|
- `wp-typia add ai-feature brief-suggestions --namespace my-plugin/v1`
|
|
23
|
+
- `wp-typia add editor-plugin review-workflow --slot sidebar`
|
|
24
|
+
- `wp-typia add editor-plugin seo-notes --slot document-setting-panel`
|
|
20
25
|
- `wp-typia add hooked-block counter-card --anchor core/post-content --position after`
|
|
21
26
|
|
|
22
27
|
`wp-typia <project-dir>` remains available as a backward-compatible alias to
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ArgvWalkerMetadata = {
|
|
2
|
+
longValueOptions: Iterable<string>;
|
|
3
|
+
shortValueOptions: Iterable<string>;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export declare function collectPositionalIndexes(
|
|
7
|
+
argv: string[],
|
|
8
|
+
metadata: ArgvWalkerMetadata,
|
|
9
|
+
): number[];
|
|
10
|
+
|
|
11
|
+
export declare function findFirstPositionalIndex(
|
|
12
|
+
argv: string[],
|
|
13
|
+
metadata: ArgvWalkerMetadata,
|
|
14
|
+
): number;
|
|
15
|
+
|
|
16
|
+
export declare function findFirstPositional(
|
|
17
|
+
argv: string[],
|
|
18
|
+
metadata: ArgvWalkerMetadata,
|
|
19
|
+
): string | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function normalizeOptionSet(values) {
|
|
2
|
+
return values instanceof Set ? values : new Set(values);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function collectPositionalIndexes(argv, metadata) {
|
|
6
|
+
const longValueOptionSet = normalizeOptionSet(metadata.longValueOptions);
|
|
7
|
+
const shortValueOptionSet = normalizeOptionSet(metadata.shortValueOptions);
|
|
8
|
+
const positionalIndexes = [];
|
|
9
|
+
|
|
10
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
11
|
+
const arg = argv[index];
|
|
12
|
+
if (arg === '--') {
|
|
13
|
+
for (let restIndex = index + 1; restIndex < argv.length; restIndex += 1) {
|
|
14
|
+
positionalIndexes.push(restIndex);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
if (!arg.startsWith('-') || arg === '-') {
|
|
19
|
+
positionalIndexes.push(index);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (arg.startsWith('--')) {
|
|
23
|
+
if (arg.includes('=')) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const next = argv[index + 1];
|
|
27
|
+
if (longValueOptionSet.has(arg) && next && !next.startsWith('-')) {
|
|
28
|
+
index += 1;
|
|
29
|
+
}
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (
|
|
33
|
+
arg.length === 2 &&
|
|
34
|
+
shortValueOptionSet.has(arg) &&
|
|
35
|
+
argv[index + 1] &&
|
|
36
|
+
!argv[index + 1].startsWith('-')
|
|
37
|
+
) {
|
|
38
|
+
index += 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return positionalIndexes;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function findFirstPositionalIndex(argv, metadata) {
|
|
46
|
+
const positionalIndexes = collectPositionalIndexes(argv, metadata);
|
|
47
|
+
return positionalIndexes[0] ?? -1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function findFirstPositional(argv, metadata) {
|
|
51
|
+
const firstPositionalIndex = findFirstPositionalIndex(argv, metadata);
|
|
52
|
+
return firstPositionalIndex === -1 ? undefined : argv[firstPositionalIndex];
|
|
53
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
// This file was automatically generated by `
|
|
1
|
+
// This file was automatically generated by `node scripts/generate-routing-metadata.mjs`.
|
|
2
2
|
// Do not edit directly.
|
|
3
3
|
|
|
4
4
|
export const fullRuntimeCommands = Object.freeze([
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
'mcp',
|
|
6
|
+
'skills',
|
|
7
|
+
'completions',
|
|
8
|
+
'complete',
|
|
9
9
|
]);
|
|
10
10
|
export const longValueOptions = Object.freeze([
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"-t"
|
|
11
|
+
'--alternate-render-targets',
|
|
12
|
+
'--anchor',
|
|
13
|
+
'--attribute',
|
|
14
|
+
'--block',
|
|
15
|
+
'--config',
|
|
16
|
+
'--current-migration-version',
|
|
17
|
+
'--data-storage',
|
|
18
|
+
'--external-layer-id',
|
|
19
|
+
'--external-layer-source',
|
|
20
|
+
'--format',
|
|
21
|
+
'--from',
|
|
22
|
+
'--from-migration-version',
|
|
23
|
+
'--id',
|
|
24
|
+
'--inner-blocks-preset',
|
|
25
|
+
'--iterations',
|
|
26
|
+
'--methods',
|
|
27
|
+
'--migration-version',
|
|
28
|
+
'--namespace',
|
|
29
|
+
'--output-dir',
|
|
30
|
+
'--package-manager',
|
|
31
|
+
'--persistence-policy',
|
|
32
|
+
'--php-prefix',
|
|
33
|
+
'--position',
|
|
34
|
+
'--query-post-type',
|
|
35
|
+
'--seed',
|
|
36
|
+
'--slot',
|
|
37
|
+
'--source',
|
|
38
|
+
'--template',
|
|
39
|
+
'--text-domain',
|
|
40
|
+
'--to',
|
|
41
|
+
'--to-migration-version',
|
|
42
|
+
'--variant',
|
|
44
43
|
]);
|
|
44
|
+
export const shortValueOptions = Object.freeze(['-c', '-p', '-t']);
|
package/bin/wp-typia.js
CHANGED
|
@@ -1,125 +1,113 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import fs from
|
|
4
|
-
import { spawnSync } from
|
|
5
|
-
import path from
|
|
6
|
-
import { fileURLToPath, pathToFileURL } from
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
fullRuntimeCommands,
|
|
10
|
+
longValueOptions,
|
|
11
|
+
shortValueOptions,
|
|
12
|
+
} from './routing-metadata.generated.js';
|
|
13
|
+
import { findFirstPositional } from './argv-walker.js';
|
|
14
|
+
|
|
15
|
+
const packageRoot = path.resolve(
|
|
16
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
17
|
+
'..',
|
|
18
|
+
);
|
|
19
|
+
const cliEntrypoint = path.join(packageRoot, 'dist-bunli', 'cli.js');
|
|
20
|
+
const nodeCliEntrypoint = path.join(packageRoot, 'dist-bunli', 'node-cli.js');
|
|
21
|
+
const bunBinary = process.env.BUN_BIN || 'bun';
|
|
18
22
|
const fullRuntimeCommandSet = new Set(fullRuntimeCommands);
|
|
19
23
|
const longValueOptionSet = new Set(longValueOptions);
|
|
20
24
|
const shortValueOptionSet = new Set(shortValueOptions);
|
|
21
|
-
const buildScriptEntrypoint = path.join(
|
|
22
|
-
|
|
25
|
+
const buildScriptEntrypoint = path.join(
|
|
26
|
+
packageRoot,
|
|
27
|
+
'scripts',
|
|
28
|
+
'build-bunli-runtime.ts',
|
|
29
|
+
);
|
|
30
|
+
const sourceCliEntrypoint = path.join(packageRoot, 'src', 'cli.ts');
|
|
23
31
|
const standaloneGuidance =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function firstPositional(argv) {
|
|
27
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
28
|
-
const arg = argv[index];
|
|
29
|
-
if (!arg || arg === "--") {
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
if (shortValueOptionSet.has(arg) || longValueOptionSet.has(arg)) {
|
|
33
|
-
index += 1;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (arg.startsWith("--")) {
|
|
37
|
-
const separatorIndex = arg.indexOf("=");
|
|
38
|
-
if (
|
|
39
|
-
separatorIndex > 0 &&
|
|
40
|
-
longValueOptionSet.has(arg.slice(0, separatorIndex))
|
|
41
|
-
) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (arg.startsWith("-") && arg !== "-") {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
return arg;
|
|
49
|
-
}
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
32
|
+
'Prefer not to install Bun? Use the standalone wp-typia binary from the GitHub release assets.';
|
|
52
33
|
|
|
53
34
|
function isWorkingBunBinary() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
const bunCheck = spawnSync(bunBinary, ['--version'], {
|
|
36
|
+
env: process.env,
|
|
37
|
+
stdio: 'ignore',
|
|
38
|
+
});
|
|
58
39
|
|
|
59
|
-
|
|
40
|
+
return !bunCheck.error && bunCheck.status === 0;
|
|
60
41
|
}
|
|
61
42
|
|
|
62
43
|
function canAutobuildSourceCheckout() {
|
|
63
|
-
|
|
44
|
+
return (
|
|
45
|
+
fs.existsSync(buildScriptEntrypoint) && fs.existsSync(sourceCliEntrypoint)
|
|
46
|
+
);
|
|
64
47
|
}
|
|
65
48
|
|
|
66
49
|
function ensureBuiltRuntime() {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
if (fs.existsSync(cliEntrypoint) && fs.existsSync(nodeCliEntrypoint)) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
70
53
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
if (!canAutobuildSourceCheckout() || !isWorkingBunBinary()) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
74
57
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
const buildResult = spawnSync(bunBinary, ['run', 'build'], {
|
|
59
|
+
cwd: packageRoot,
|
|
60
|
+
env: process.env,
|
|
61
|
+
stdio: 'inherit',
|
|
62
|
+
});
|
|
80
63
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
if (buildResult.status !== 0) {
|
|
65
|
+
process.exit(buildResult.status ?? 1);
|
|
66
|
+
}
|
|
84
67
|
|
|
85
|
-
|
|
68
|
+
return fs.existsSync(cliEntrypoint) && fs.existsSync(nodeCliEntrypoint);
|
|
86
69
|
}
|
|
87
70
|
|
|
88
71
|
const argv = process.argv.slice(2);
|
|
89
|
-
const command =
|
|
90
|
-
|
|
72
|
+
const command = findFirstPositional(argv, {
|
|
73
|
+
longValueOptions: longValueOptionSet,
|
|
74
|
+
shortValueOptions: shortValueOptionSet,
|
|
75
|
+
});
|
|
76
|
+
const shouldUseFullRuntime = command
|
|
77
|
+
? fullRuntimeCommandSet.has(command)
|
|
78
|
+
: false;
|
|
91
79
|
const hasBuiltRuntime = ensureBuiltRuntime();
|
|
92
80
|
const hasWorkingBun = isWorkingBunBinary();
|
|
93
81
|
|
|
94
82
|
// Keep common help on the human-readable Node fallback even when Bun is present.
|
|
95
83
|
if (hasWorkingBun && hasBuiltRuntime && shouldUseFullRuntime) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
84
|
+
const result = spawnSync(bunBinary, [cliEntrypoint, ...argv], {
|
|
85
|
+
cwd: process.cwd(),
|
|
86
|
+
env: process.env,
|
|
87
|
+
stdio: 'inherit',
|
|
88
|
+
});
|
|
89
|
+
process.exit(result.status ?? 1);
|
|
102
90
|
}
|
|
103
91
|
|
|
104
92
|
if (shouldUseFullRuntime) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
if (!hasBuiltRuntime) {
|
|
94
|
+
console.error(
|
|
95
|
+
'Error: wp-typia could not locate its built CLI runtime. Reinstall the published package, or run `bun run build` when using a source checkout.',
|
|
96
|
+
);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.error(
|
|
101
|
+
`Error: wp-typia ${command} requires Bun. Install Bun locally, run with bunx, or set BUN_BIN to a working Bun executable. ${standaloneGuidance}`,
|
|
102
|
+
);
|
|
103
|
+
process.exit(1);
|
|
116
104
|
}
|
|
117
105
|
|
|
118
106
|
if (!hasBuiltRuntime || !fs.existsSync(nodeCliEntrypoint)) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
107
|
+
console.error(
|
|
108
|
+
'Error: wp-typia could not locate its Node fallback runtime. Reinstall the published package, or run `bun run build` when using a source checkout.',
|
|
109
|
+
);
|
|
110
|
+
process.exit(1);
|
|
123
111
|
}
|
|
124
112
|
|
|
125
113
|
const cliModule = await import(pathToFileURL(nodeCliEntrypoint).href);
|