@moku-labs/native 0.3.2 → 0.3.4
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 +2 -2
- package/dist/index.cjs +82 -15
- package/dist/index.mjs +82 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
## Quick start
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
|
-
bun add @moku-labs/native
|
|
32
|
+
bun add @moku-labs/native @moku-labs/core @moku-labs/common
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
> [!NOTE]
|
|
36
|
-
> **Status: `0.x` — early.** `@moku-labs/core` and `@moku-labs/common`
|
|
36
|
+
> **Status: `0.x` — early.** `@moku-labs/core` (`^1.7.1`) and `@moku-labs/common` (`^0.3.4`) are peer dependencies — install them beside the package, as above. A real `node` binary on PATH is a hard prerequisite (`@tauri-apps/cli` cannot run under bun); `native doctor` checks it.
|
|
37
37
|
|
|
38
38
|
A native app is its own `createApp` — typically `src/native.ts`, beside your web app:
|
|
39
39
|
|
package/dist/index.cjs
CHANGED
|
@@ -7016,6 +7016,7 @@ const versionsCheck = {
|
|
|
7016
7016
|
/**
|
|
7017
7017
|
* @file doctor plugin check — web.build/web.devCommand scripts exist, resolved from the
|
|
7018
7018
|
* SAME root Tauri will use (`web.cwd` override honored, else the consumer root).
|
|
7019
|
+
* Only a package-manager call (`bun run build`) names a script; a direct command is not checked.
|
|
7019
7020
|
* Necessary-not-sufficient (documented):
|
|
7020
7021
|
* this never executes the script, only confirms package.json declares it.
|
|
7021
7022
|
*/
|
|
@@ -7034,26 +7035,78 @@ const versionsCheck = {
|
|
|
7034
7035
|
function resolveWebCwd(global) {
|
|
7035
7036
|
return node_path.default.resolve(global.web.cwd ?? ".");
|
|
7036
7037
|
}
|
|
7038
|
+
/** Package managers whose `<pm> run <script>` (or `<pm> <script>`) names a package.json script. */
|
|
7039
|
+
const PACKAGE_MANAGERS = /* @__PURE__ */ new Set([
|
|
7040
|
+
"bun",
|
|
7041
|
+
"npm",
|
|
7042
|
+
"pnpm",
|
|
7043
|
+
"yarn"
|
|
7044
|
+
]);
|
|
7045
|
+
/** Package-manager subcommands that run a binary, not a package.json script. */
|
|
7046
|
+
const NON_SCRIPT_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
7047
|
+
"x",
|
|
7048
|
+
"exec",
|
|
7049
|
+
"dlx",
|
|
7050
|
+
"install",
|
|
7051
|
+
"add",
|
|
7052
|
+
"create"
|
|
7053
|
+
]);
|
|
7054
|
+
/**
|
|
7055
|
+
* Splits a shell command into tokens, honoring single and double quotes.
|
|
7056
|
+
*
|
|
7057
|
+
* @param command - The configured shell command.
|
|
7058
|
+
* @returns The tokens with their quotes removed.
|
|
7059
|
+
* @example
|
|
7060
|
+
* ```ts
|
|
7061
|
+
* tokenize('"/opt/bin/bun" game.mjs build'); // ["/opt/bin/bun", "game.mjs", "build"]
|
|
7062
|
+
* ```
|
|
7063
|
+
*/
|
|
7064
|
+
function tokenize(command) {
|
|
7065
|
+
const tokens = [];
|
|
7066
|
+
for (const match of command.matchAll(/"([^"]*)"|'([^']*)'|(\S+)/g)) tokens.push(match[1] ?? match[2] ?? match[3] ?? "");
|
|
7067
|
+
return tokens;
|
|
7068
|
+
}
|
|
7037
7069
|
/**
|
|
7038
|
-
* Extracts the package.json script name a command invokes
|
|
7039
|
-
*
|
|
7070
|
+
* Extracts the package.json script name a command invokes. Only a package-manager call
|
|
7071
|
+
* names a script: `<pm> run <script>`, or the `<pm> <script>` shorthand when the second
|
|
7072
|
+
* token is a bare word. Anything else is a direct command.
|
|
7040
7073
|
*
|
|
7041
7074
|
* @param command - The configured shell command.
|
|
7042
|
-
* @returns The
|
|
7075
|
+
* @returns The script name, or `undefined` for a direct command.
|
|
7043
7076
|
* @example
|
|
7044
7077
|
* ```ts
|
|
7045
7078
|
* extractScriptName("bun run build"); // "build"
|
|
7046
7079
|
* ```
|
|
7047
7080
|
*/
|
|
7048
7081
|
function extractScriptName(command) {
|
|
7049
|
-
const tokens = command
|
|
7082
|
+
const tokens = tokenize(command);
|
|
7083
|
+
const executable = node_path.default.basename(tokens[0] ?? "").replace(/\.(exe|cmd)$/i, "");
|
|
7084
|
+
if (!PACKAGE_MANAGERS.has(executable)) return void 0;
|
|
7050
7085
|
const runIndex = tokens.indexOf("run");
|
|
7051
|
-
|
|
7086
|
+
if (runIndex !== -1) return tokens[runIndex + 1];
|
|
7087
|
+
const shorthand = tokens[1];
|
|
7088
|
+
if (shorthand === void 0 || NON_SCRIPT_SUBCOMMANDS.has(shorthand)) return void 0;
|
|
7089
|
+
return /^[\w:-]+$/.test(shorthand) ? shorthand : void 0;
|
|
7090
|
+
}
|
|
7091
|
+
/**
|
|
7092
|
+
* Builds the note for config keys whose command is direct, not a package script.
|
|
7093
|
+
*
|
|
7094
|
+
* @param keys - The config keys with a direct command.
|
|
7095
|
+
* @returns The note with a leading space, or `""` when there are none.
|
|
7096
|
+
* @example
|
|
7097
|
+
* ```ts
|
|
7098
|
+
* describeDirect(["web.build"]); // " web.build is a direct command, not a package script; not checked."
|
|
7099
|
+
* ```
|
|
7100
|
+
*/
|
|
7101
|
+
function describeDirect(keys) {
|
|
7102
|
+
if (keys.length === 0) return "";
|
|
7103
|
+
if (keys.length === 1) return ` ${keys[0]} is a direct command, not a package script; not checked.`;
|
|
7104
|
+
return ` ${keys.join(" and ")} are direct commands, not package scripts; not checked.`;
|
|
7052
7105
|
}
|
|
7053
7106
|
/**
|
|
7054
|
-
* Confirms `web.build`/`web.devCommand
|
|
7055
|
-
* `package.json`.
|
|
7056
|
-
*
|
|
7107
|
+
* Confirms that `web.build`/`web.devCommand`, when they call a package script, name a
|
|
7108
|
+
* script present in the resolved cwd's `package.json`. A direct command is not checked.
|
|
7109
|
+
* Presence is necessary but not sufficient: the script itself is never executed.
|
|
7057
7110
|
*
|
|
7058
7111
|
* @param input - The check input (host-scoped).
|
|
7059
7112
|
* @returns The check result.
|
|
@@ -7063,6 +7116,24 @@ function extractScriptName(command) {
|
|
|
7063
7116
|
* ```
|
|
7064
7117
|
*/
|
|
7065
7118
|
async function run$1(input) {
|
|
7119
|
+
const commands = [{
|
|
7120
|
+
key: "web.build",
|
|
7121
|
+
command: input.global.web.build
|
|
7122
|
+
}, {
|
|
7123
|
+
key: "web.devCommand",
|
|
7124
|
+
command: input.global.web.devCommand
|
|
7125
|
+
}].map((entry) => ({
|
|
7126
|
+
...entry,
|
|
7127
|
+
script: extractScriptName(entry.command)
|
|
7128
|
+
}));
|
|
7129
|
+
const direct = commands.filter((entry) => entry.script === void 0);
|
|
7130
|
+
const directNote = describeDirect(direct.map((entry) => entry.key));
|
|
7131
|
+
if (direct.length === commands.length) return {
|
|
7132
|
+
id: "web-script",
|
|
7133
|
+
target: "host",
|
|
7134
|
+
status: "pass",
|
|
7135
|
+
message: `[native]${directNote}`
|
|
7136
|
+
};
|
|
7066
7137
|
const cwd = resolveWebCwd(input.global);
|
|
7067
7138
|
const packageJsonPath = node_path.default.join(cwd, "package.json");
|
|
7068
7139
|
let raw;
|
|
@@ -7089,23 +7160,19 @@ async function run$1(input) {
|
|
|
7089
7160
|
fixIt: `fix ${packageJsonPath}`
|
|
7090
7161
|
};
|
|
7091
7162
|
}
|
|
7092
|
-
const
|
|
7093
|
-
const devScript = extractScriptName(input.global.web.devCommand);
|
|
7094
|
-
const missing = [];
|
|
7095
|
-
if (!buildScript || !(buildScript in scripts)) missing.push(`web.build ("${input.global.web.build}")`);
|
|
7096
|
-
if (!devScript || !(devScript in scripts)) missing.push(`web.devCommand ("${input.global.web.devCommand}")`);
|
|
7163
|
+
const missing = commands.filter((entry) => entry.script !== void 0 && !(entry.script in scripts)).map((entry) => `${entry.key} ("${entry.command}")`);
|
|
7097
7164
|
if (missing.length > 0) return {
|
|
7098
7165
|
id: "web-script",
|
|
7099
7166
|
target: "host",
|
|
7100
7167
|
status: "fail",
|
|
7101
|
-
message: `[native] script(s) not found in ${packageJsonPath}: ${missing.join(", ")}. Presence is necessary but not sufficient — this does not run the script
|
|
7168
|
+
message: `[native] script(s) not found in ${packageJsonPath}: ${missing.join(", ")}. Presence is necessary but not sufficient — this does not run the script.${directNote}`,
|
|
7102
7169
|
fixIt: `add the missing script(s) to ${packageJsonPath}, or update config.web to match existing scripts`
|
|
7103
7170
|
};
|
|
7104
7171
|
return {
|
|
7105
7172
|
id: "web-script",
|
|
7106
7173
|
target: "host",
|
|
7107
7174
|
status: "pass",
|
|
7108
|
-
message: `[native]
|
|
7175
|
+
message: `[native] package scripts resolved in ${packageJsonPath} (not executed).${directNote}`
|
|
7109
7176
|
};
|
|
7110
7177
|
}
|
|
7111
7178
|
/** web.build/web.devCommand script presence — resolved from Tauri's own cwd. */
|
package/dist/index.mjs
CHANGED
|
@@ -6989,6 +6989,7 @@ const versionsCheck = {
|
|
|
6989
6989
|
/**
|
|
6990
6990
|
* @file doctor plugin check — web.build/web.devCommand scripts exist, resolved from the
|
|
6991
6991
|
* SAME root Tauri will use (`web.cwd` override honored, else the consumer root).
|
|
6992
|
+
* Only a package-manager call (`bun run build`) names a script; a direct command is not checked.
|
|
6992
6993
|
* Necessary-not-sufficient (documented):
|
|
6993
6994
|
* this never executes the script, only confirms package.json declares it.
|
|
6994
6995
|
*/
|
|
@@ -7007,26 +7008,78 @@ const versionsCheck = {
|
|
|
7007
7008
|
function resolveWebCwd(global) {
|
|
7008
7009
|
return path.resolve(global.web.cwd ?? ".");
|
|
7009
7010
|
}
|
|
7011
|
+
/** Package managers whose `<pm> run <script>` (or `<pm> <script>`) names a package.json script. */
|
|
7012
|
+
const PACKAGE_MANAGERS = /* @__PURE__ */ new Set([
|
|
7013
|
+
"bun",
|
|
7014
|
+
"npm",
|
|
7015
|
+
"pnpm",
|
|
7016
|
+
"yarn"
|
|
7017
|
+
]);
|
|
7018
|
+
/** Package-manager subcommands that run a binary, not a package.json script. */
|
|
7019
|
+
const NON_SCRIPT_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
7020
|
+
"x",
|
|
7021
|
+
"exec",
|
|
7022
|
+
"dlx",
|
|
7023
|
+
"install",
|
|
7024
|
+
"add",
|
|
7025
|
+
"create"
|
|
7026
|
+
]);
|
|
7027
|
+
/**
|
|
7028
|
+
* Splits a shell command into tokens, honoring single and double quotes.
|
|
7029
|
+
*
|
|
7030
|
+
* @param command - The configured shell command.
|
|
7031
|
+
* @returns The tokens with their quotes removed.
|
|
7032
|
+
* @example
|
|
7033
|
+
* ```ts
|
|
7034
|
+
* tokenize('"/opt/bin/bun" game.mjs build'); // ["/opt/bin/bun", "game.mjs", "build"]
|
|
7035
|
+
* ```
|
|
7036
|
+
*/
|
|
7037
|
+
function tokenize(command) {
|
|
7038
|
+
const tokens = [];
|
|
7039
|
+
for (const match of command.matchAll(/"([^"]*)"|'([^']*)'|(\S+)/g)) tokens.push(match[1] ?? match[2] ?? match[3] ?? "");
|
|
7040
|
+
return tokens;
|
|
7041
|
+
}
|
|
7010
7042
|
/**
|
|
7011
|
-
* Extracts the package.json script name a command invokes
|
|
7012
|
-
*
|
|
7043
|
+
* Extracts the package.json script name a command invokes. Only a package-manager call
|
|
7044
|
+
* names a script: `<pm> run <script>`, or the `<pm> <script>` shorthand when the second
|
|
7045
|
+
* token is a bare word. Anything else is a direct command.
|
|
7013
7046
|
*
|
|
7014
7047
|
* @param command - The configured shell command.
|
|
7015
|
-
* @returns The
|
|
7048
|
+
* @returns The script name, or `undefined` for a direct command.
|
|
7016
7049
|
* @example
|
|
7017
7050
|
* ```ts
|
|
7018
7051
|
* extractScriptName("bun run build"); // "build"
|
|
7019
7052
|
* ```
|
|
7020
7053
|
*/
|
|
7021
7054
|
function extractScriptName(command) {
|
|
7022
|
-
const tokens = command
|
|
7055
|
+
const tokens = tokenize(command);
|
|
7056
|
+
const executable = path.basename(tokens[0] ?? "").replace(/\.(exe|cmd)$/i, "");
|
|
7057
|
+
if (!PACKAGE_MANAGERS.has(executable)) return void 0;
|
|
7023
7058
|
const runIndex = tokens.indexOf("run");
|
|
7024
|
-
|
|
7059
|
+
if (runIndex !== -1) return tokens[runIndex + 1];
|
|
7060
|
+
const shorthand = tokens[1];
|
|
7061
|
+
if (shorthand === void 0 || NON_SCRIPT_SUBCOMMANDS.has(shorthand)) return void 0;
|
|
7062
|
+
return /^[\w:-]+$/.test(shorthand) ? shorthand : void 0;
|
|
7063
|
+
}
|
|
7064
|
+
/**
|
|
7065
|
+
* Builds the note for config keys whose command is direct, not a package script.
|
|
7066
|
+
*
|
|
7067
|
+
* @param keys - The config keys with a direct command.
|
|
7068
|
+
* @returns The note with a leading space, or `""` when there are none.
|
|
7069
|
+
* @example
|
|
7070
|
+
* ```ts
|
|
7071
|
+
* describeDirect(["web.build"]); // " web.build is a direct command, not a package script; not checked."
|
|
7072
|
+
* ```
|
|
7073
|
+
*/
|
|
7074
|
+
function describeDirect(keys) {
|
|
7075
|
+
if (keys.length === 0) return "";
|
|
7076
|
+
if (keys.length === 1) return ` ${keys[0]} is a direct command, not a package script; not checked.`;
|
|
7077
|
+
return ` ${keys.join(" and ")} are direct commands, not package scripts; not checked.`;
|
|
7025
7078
|
}
|
|
7026
7079
|
/**
|
|
7027
|
-
* Confirms `web.build`/`web.devCommand
|
|
7028
|
-
* `package.json`.
|
|
7029
|
-
*
|
|
7080
|
+
* Confirms that `web.build`/`web.devCommand`, when they call a package script, name a
|
|
7081
|
+
* script present in the resolved cwd's `package.json`. A direct command is not checked.
|
|
7082
|
+
* Presence is necessary but not sufficient: the script itself is never executed.
|
|
7030
7083
|
*
|
|
7031
7084
|
* @param input - The check input (host-scoped).
|
|
7032
7085
|
* @returns The check result.
|
|
@@ -7036,6 +7089,24 @@ function extractScriptName(command) {
|
|
|
7036
7089
|
* ```
|
|
7037
7090
|
*/
|
|
7038
7091
|
async function run$1(input) {
|
|
7092
|
+
const commands = [{
|
|
7093
|
+
key: "web.build",
|
|
7094
|
+
command: input.global.web.build
|
|
7095
|
+
}, {
|
|
7096
|
+
key: "web.devCommand",
|
|
7097
|
+
command: input.global.web.devCommand
|
|
7098
|
+
}].map((entry) => ({
|
|
7099
|
+
...entry,
|
|
7100
|
+
script: extractScriptName(entry.command)
|
|
7101
|
+
}));
|
|
7102
|
+
const direct = commands.filter((entry) => entry.script === void 0);
|
|
7103
|
+
const directNote = describeDirect(direct.map((entry) => entry.key));
|
|
7104
|
+
if (direct.length === commands.length) return {
|
|
7105
|
+
id: "web-script",
|
|
7106
|
+
target: "host",
|
|
7107
|
+
status: "pass",
|
|
7108
|
+
message: `[native]${directNote}`
|
|
7109
|
+
};
|
|
7039
7110
|
const cwd = resolveWebCwd(input.global);
|
|
7040
7111
|
const packageJsonPath = path.join(cwd, "package.json");
|
|
7041
7112
|
let raw;
|
|
@@ -7062,23 +7133,19 @@ async function run$1(input) {
|
|
|
7062
7133
|
fixIt: `fix ${packageJsonPath}`
|
|
7063
7134
|
};
|
|
7064
7135
|
}
|
|
7065
|
-
const
|
|
7066
|
-
const devScript = extractScriptName(input.global.web.devCommand);
|
|
7067
|
-
const missing = [];
|
|
7068
|
-
if (!buildScript || !(buildScript in scripts)) missing.push(`web.build ("${input.global.web.build}")`);
|
|
7069
|
-
if (!devScript || !(devScript in scripts)) missing.push(`web.devCommand ("${input.global.web.devCommand}")`);
|
|
7136
|
+
const missing = commands.filter((entry) => entry.script !== void 0 && !(entry.script in scripts)).map((entry) => `${entry.key} ("${entry.command}")`);
|
|
7070
7137
|
if (missing.length > 0) return {
|
|
7071
7138
|
id: "web-script",
|
|
7072
7139
|
target: "host",
|
|
7073
7140
|
status: "fail",
|
|
7074
|
-
message: `[native] script(s) not found in ${packageJsonPath}: ${missing.join(", ")}. Presence is necessary but not sufficient — this does not run the script
|
|
7141
|
+
message: `[native] script(s) not found in ${packageJsonPath}: ${missing.join(", ")}. Presence is necessary but not sufficient — this does not run the script.${directNote}`,
|
|
7075
7142
|
fixIt: `add the missing script(s) to ${packageJsonPath}, or update config.web to match existing scripts`
|
|
7076
7143
|
};
|
|
7077
7144
|
return {
|
|
7078
7145
|
id: "web-script",
|
|
7079
7146
|
target: "host",
|
|
7080
7147
|
status: "pass",
|
|
7081
|
-
message: `[native]
|
|
7148
|
+
message: `[native] package scripts resolved in ${packageJsonPath} (not executed).${directNote}`
|
|
7082
7149
|
};
|
|
7083
7150
|
}
|
|
7084
7151
|
/** web.build/web.devCommand script presence — resolved from Tauri's own cwd. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moku-labs/native",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Node-only native packager framework for Moku — generates a gitignored Tauri project, codegens capabilities/Info.plist/AndroidManifest from composed system plugins, and runs tauri build.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@arethetypeswrong/cli": "0.18.3",
|
|
67
67
|
"@arethetypeswrong/core": "0.18.3",
|
|
68
68
|
"@biomejs/biome": "2.4.16",
|
|
69
|
-
"@moku-labs/ci": "1.
|
|
69
|
+
"@moku-labs/ci": "1.3.0",
|
|
70
70
|
"@moku-labs/common": "0.3.4",
|
|
71
71
|
"@moku-labs/core": "1.7.1",
|
|
72
72
|
"@types/bun": "1.3.14",
|