@moku-labs/native 0.3.14 → 0.3.15
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/dist/index.cjs +50 -20
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +50 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3050,13 +3050,16 @@ async function patchAndroidIcon(options) {
|
|
|
3050
3050
|
//#endregion
|
|
3051
3051
|
//#region src/plugins/project/mobile/identity.ts
|
|
3052
3052
|
/**
|
|
3053
|
-
* @file project plugin — the app id a `gen
|
|
3054
|
-
* tree aside when that id is not the configured one. `tauri android init` bakes the
|
|
3055
|
-
* the namespace, the `applicationId` and the Kotlin package path;
|
|
3056
|
-
*
|
|
3053
|
+
* @file project plugin — the app id a mobile `gen/<platform>` tree was initialised for, and
|
|
3054
|
+
* setting a tree aside when that id is not the configured one. `tauri android init` bakes the
|
|
3055
|
+
* id into the namespace, the `applicationId` and the Kotlin package path; `tauri ios init`
|
|
3056
|
+
* bakes it into `project.yml` and the Xcode project. A kept tree never runs init again, so a
|
|
3057
|
+
* changed `app.identifier` would otherwise build against the old package or bundle id.
|
|
3057
3058
|
*/
|
|
3058
3059
|
/** The key of the `applicationId = "<id>"` line; the debug suffix is a separate line. */
|
|
3059
3060
|
const APPLICATION_ID_KEY = "applicationId";
|
|
3061
|
+
/** The key of the `PRODUCT_BUNDLE_IDENTIFIER: <id>` line of `project.yml`. */
|
|
3062
|
+
const BUNDLE_IDENTIFIER_KEY = "PRODUCT_BUNDLE_IDENTIFIER";
|
|
3060
3063
|
/**
|
|
3061
3064
|
* Reads the `applicationId` a `gen/android` tree was initialised for. Only a quoted literal
|
|
3062
3065
|
* is recognised, the form `tauri android init` writes; an expression reads as no id.
|
|
@@ -3077,13 +3080,34 @@ function readAndroidApplicationId(genDirectory) {
|
|
|
3077
3080
|
}
|
|
3078
3081
|
}
|
|
3079
3082
|
/**
|
|
3080
|
-
*
|
|
3083
|
+
* Reads the bundle id a `gen/apple` tree was initialised for, from the
|
|
3084
|
+
* `PRODUCT_BUNDLE_IDENTIFIER` of its `project.yml` — the file the Xcode project is generated
|
|
3085
|
+
* from, so both carry the same id. A quoted value is read without its quotes.
|
|
3086
|
+
*
|
|
3087
|
+
* @param genDirectory - The absolute `src-tauri/gen/apple` directory.
|
|
3088
|
+
* @returns The id, or undefined when `project.yml` is absent or names no bundle id.
|
|
3089
|
+
* @example
|
|
3090
|
+
* ```ts
|
|
3091
|
+
* readAppleBundleIdentifier("/repo/.moku/tauri/src-tauri/gen/apple"); // "com.acme.demo"
|
|
3092
|
+
* ```
|
|
3093
|
+
*/
|
|
3094
|
+
function readAppleBundleIdentifier(genDirectory) {
|
|
3095
|
+
const projectPath = node_path.default.join(genDirectory, "project.yml");
|
|
3096
|
+
if (!(0, node_fs.existsSync)(projectPath)) return void 0;
|
|
3097
|
+
for (const line of (0, node_fs.readFileSync)(projectPath, "utf8").split("\n")) {
|
|
3098
|
+
const [key, value] = line.split(":", 2).map((part) => part.trim());
|
|
3099
|
+
if (key === BUNDLE_IDENTIFIER_KEY && value) return value.replaceAll(/["']/g, "");
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
/**
|
|
3103
|
+
* Compares two app ids the way Tauri writes them: a `-` may come out as `_` on Android and
|
|
3104
|
+
* a `_` as `-` on Apple.
|
|
3081
3105
|
*
|
|
3082
3106
|
* @param left - One id.
|
|
3083
3107
|
* @param right - The other id.
|
|
3084
3108
|
* @returns Whether both name the same app.
|
|
3085
3109
|
*/
|
|
3086
|
-
function
|
|
3110
|
+
function sameAppId(left, right) {
|
|
3087
3111
|
return left.replaceAll("-", "_") === right.replaceAll("-", "_");
|
|
3088
3112
|
}
|
|
3089
3113
|
/**
|
|
@@ -3105,24 +3129,30 @@ function freeAsidePath(genDirectory, found) {
|
|
|
3105
3129
|
return candidate;
|
|
3106
3130
|
}
|
|
3107
3131
|
/**
|
|
3108
|
-
* Moves a `gen/android` tree aside when it was initialised for another app id,
|
|
3109
|
-
* `tauri android init` writes a fresh one. The tree is renamed, never deleted:
|
|
3110
|
-
* keystore or hand edits. A tree whose id cannot be read is left to the
|
|
3132
|
+
* Moves a `gen/android` or `gen/apple` tree aside when it was initialised for another app id,
|
|
3133
|
+
* so the next `tauri android|ios init` writes a fresh one. The tree is renamed, never deleted:
|
|
3134
|
+
* it may hold a keystore or hand edits. A tree whose id cannot be read is left to the
|
|
3135
|
+
* completeness gate.
|
|
3111
3136
|
*
|
|
3112
3137
|
* @param options - The check options.
|
|
3113
|
-
* @param options.
|
|
3138
|
+
* @param options.target - The mobile platform the tree belongs to.
|
|
3139
|
+
* @param options.genDirectory - The absolute `src-tauri/gen/<platform>` directory.
|
|
3114
3140
|
* @param options.identifier - The configured `app.identifier`.
|
|
3115
3141
|
* @returns What was found and where it went, or undefined when the tree was kept.
|
|
3116
3142
|
* @example
|
|
3117
3143
|
* ```ts
|
|
3118
|
-
* await
|
|
3144
|
+
* await setAsideStaleMobileTree({
|
|
3145
|
+
* target: "android",
|
|
3146
|
+
* genDirectory,
|
|
3147
|
+
* identifier: "studio.kitto.memorymissing"
|
|
3148
|
+
* });
|
|
3119
3149
|
* // { found: "com.mokulabs.memorymissing", expected: "studio.kitto.memorymissing",
|
|
3120
3150
|
* // movedTo: ".../gen/android.old-com.mokulabs.memorymissing" }
|
|
3121
3151
|
* ```
|
|
3122
3152
|
*/
|
|
3123
|
-
async function
|
|
3124
|
-
const found = readAndroidApplicationId(options.genDirectory);
|
|
3125
|
-
if (found === void 0 ||
|
|
3153
|
+
async function setAsideStaleMobileTree(options) {
|
|
3154
|
+
const found = options.target === "android" ? readAndroidApplicationId(options.genDirectory) : readAppleBundleIdentifier(options.genDirectory);
|
|
3155
|
+
if (found === void 0 || sameAppId(found, options.identifier)) return void 0;
|
|
3126
3156
|
const movedTo = freeAsidePath(options.genDirectory, found);
|
|
3127
3157
|
await (0, node_fs_promises.rename)(options.genDirectory, movedTo);
|
|
3128
3158
|
return {
|
|
@@ -6627,20 +6657,20 @@ function createProjectApi(ctx) {
|
|
|
6627
6657
|
*/
|
|
6628
6658
|
const checkCompleteness = (opts) => completeness(ctx.global.projectDir, opts.target);
|
|
6629
6659
|
/**
|
|
6630
|
-
* Implements {@link Api.setAsideStaleTree}:
|
|
6631
|
-
* was moved.
|
|
6660
|
+
* Implements {@link Api.setAsideStaleTree}: one plain warn line when a tree was moved.
|
|
6632
6661
|
*
|
|
6633
6662
|
* @param opts - See {@link Api.setAsideStaleTree}.
|
|
6634
6663
|
* @param opts.target - The mobile platform whose tree to check.
|
|
6635
6664
|
* @returns See {@link Api.setAsideStaleTree}.
|
|
6636
6665
|
*/
|
|
6637
6666
|
const runSetAsideStaleTree = async (opts) => {
|
|
6638
|
-
|
|
6639
|
-
const aside = await
|
|
6640
|
-
|
|
6667
|
+
const genDirectory = genDirectoryPath(ctx.global.projectDir, opts.target);
|
|
6668
|
+
const aside = await setAsideStaleMobileTree({
|
|
6669
|
+
target: opts.target,
|
|
6670
|
+
genDirectory,
|
|
6641
6671
|
identifier: ctx.global.app.identifier
|
|
6642
6672
|
});
|
|
6643
|
-
if (aside !== void 0) ctx.log.warn(`gen
|
|
6673
|
+
if (aside !== void 0) ctx.log.warn(`gen/${node_path.default.basename(genDirectory)} was made for ${aside.found}, not ${aside.expected}: moved it to ${node_path.default.basename(aside.movedTo)} and generating it again`);
|
|
6644
6674
|
return aside;
|
|
6645
6675
|
};
|
|
6646
6676
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -574,11 +574,12 @@ type Api$4 = {
|
|
|
574
574
|
target: Target;
|
|
575
575
|
}): CompletenessResult;
|
|
576
576
|
/**
|
|
577
|
-
* Sets a `gen/android` tree aside when it was initialised for another app id
|
|
578
|
-
* `app.identifier
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
* tree
|
|
577
|
+
* Sets a `gen/android` or `gen/apple` tree aside when it was initialised for another app id
|
|
578
|
+
* than `app.identifier` (Android: `applicationId` in `app/build.gradle.kts`; iOS:
|
|
579
|
+
* `PRODUCT_BUNDLE_IDENTIFIER` in `project.yml`): renames it to `gen/<platform>.old-<old id>`
|
|
580
|
+
* (never deletes it, it may hold a keystore or hand edits) and logs one line, so the build's
|
|
581
|
+
* mobile init writes a fresh tree. The build plugin calls it before the completeness read.
|
|
582
|
+
* A missing tree and a tree whose id cannot be read get undefined.
|
|
582
583
|
*
|
|
583
584
|
* @param opts - The check options.
|
|
584
585
|
* @param opts.target - The mobile platform whose tree to check.
|
package/dist/index.d.mts
CHANGED
|
@@ -575,11 +575,12 @@ type Api$4 = {
|
|
|
575
575
|
target: Target;
|
|
576
576
|
}): CompletenessResult;
|
|
577
577
|
/**
|
|
578
|
-
* Sets a `gen/android` tree aside when it was initialised for another app id
|
|
579
|
-
* `app.identifier
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* tree
|
|
578
|
+
* Sets a `gen/android` or `gen/apple` tree aside when it was initialised for another app id
|
|
579
|
+
* than `app.identifier` (Android: `applicationId` in `app/build.gradle.kts`; iOS:
|
|
580
|
+
* `PRODUCT_BUNDLE_IDENTIFIER` in `project.yml`): renames it to `gen/<platform>.old-<old id>`
|
|
581
|
+
* (never deletes it, it may hold a keystore or hand edits) and logs one line, so the build's
|
|
582
|
+
* mobile init writes a fresh tree. The build plugin calls it before the completeness read.
|
|
583
|
+
* A missing tree and a tree whose id cannot be read get undefined.
|
|
583
584
|
*
|
|
584
585
|
* @param opts - The check options.
|
|
585
586
|
* @param opts.target - The mobile platform whose tree to check.
|
package/dist/index.mjs
CHANGED
|
@@ -3023,13 +3023,16 @@ async function patchAndroidIcon(options) {
|
|
|
3023
3023
|
//#endregion
|
|
3024
3024
|
//#region src/plugins/project/mobile/identity.ts
|
|
3025
3025
|
/**
|
|
3026
|
-
* @file project plugin — the app id a `gen
|
|
3027
|
-
* tree aside when that id is not the configured one. `tauri android init` bakes the
|
|
3028
|
-
* the namespace, the `applicationId` and the Kotlin package path;
|
|
3029
|
-
*
|
|
3026
|
+
* @file project plugin — the app id a mobile `gen/<platform>` tree was initialised for, and
|
|
3027
|
+
* setting a tree aside when that id is not the configured one. `tauri android init` bakes the
|
|
3028
|
+
* id into the namespace, the `applicationId` and the Kotlin package path; `tauri ios init`
|
|
3029
|
+
* bakes it into `project.yml` and the Xcode project. A kept tree never runs init again, so a
|
|
3030
|
+
* changed `app.identifier` would otherwise build against the old package or bundle id.
|
|
3030
3031
|
*/
|
|
3031
3032
|
/** The key of the `applicationId = "<id>"` line; the debug suffix is a separate line. */
|
|
3032
3033
|
const APPLICATION_ID_KEY = "applicationId";
|
|
3034
|
+
/** The key of the `PRODUCT_BUNDLE_IDENTIFIER: <id>` line of `project.yml`. */
|
|
3035
|
+
const BUNDLE_IDENTIFIER_KEY = "PRODUCT_BUNDLE_IDENTIFIER";
|
|
3033
3036
|
/**
|
|
3034
3037
|
* Reads the `applicationId` a `gen/android` tree was initialised for. Only a quoted literal
|
|
3035
3038
|
* is recognised, the form `tauri android init` writes; an expression reads as no id.
|
|
@@ -3050,13 +3053,34 @@ function readAndroidApplicationId(genDirectory) {
|
|
|
3050
3053
|
}
|
|
3051
3054
|
}
|
|
3052
3055
|
/**
|
|
3053
|
-
*
|
|
3056
|
+
* Reads the bundle id a `gen/apple` tree was initialised for, from the
|
|
3057
|
+
* `PRODUCT_BUNDLE_IDENTIFIER` of its `project.yml` — the file the Xcode project is generated
|
|
3058
|
+
* from, so both carry the same id. A quoted value is read without its quotes.
|
|
3059
|
+
*
|
|
3060
|
+
* @param genDirectory - The absolute `src-tauri/gen/apple` directory.
|
|
3061
|
+
* @returns The id, or undefined when `project.yml` is absent or names no bundle id.
|
|
3062
|
+
* @example
|
|
3063
|
+
* ```ts
|
|
3064
|
+
* readAppleBundleIdentifier("/repo/.moku/tauri/src-tauri/gen/apple"); // "com.acme.demo"
|
|
3065
|
+
* ```
|
|
3066
|
+
*/
|
|
3067
|
+
function readAppleBundleIdentifier(genDirectory) {
|
|
3068
|
+
const projectPath = path.join(genDirectory, "project.yml");
|
|
3069
|
+
if (!existsSync(projectPath)) return void 0;
|
|
3070
|
+
for (const line of readFileSync(projectPath, "utf8").split("\n")) {
|
|
3071
|
+
const [key, value] = line.split(":", 2).map((part) => part.trim());
|
|
3072
|
+
if (key === BUNDLE_IDENTIFIER_KEY && value) return value.replaceAll(/["']/g, "");
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
/**
|
|
3076
|
+
* Compares two app ids the way Tauri writes them: a `-` may come out as `_` on Android and
|
|
3077
|
+
* a `_` as `-` on Apple.
|
|
3054
3078
|
*
|
|
3055
3079
|
* @param left - One id.
|
|
3056
3080
|
* @param right - The other id.
|
|
3057
3081
|
* @returns Whether both name the same app.
|
|
3058
3082
|
*/
|
|
3059
|
-
function
|
|
3083
|
+
function sameAppId(left, right) {
|
|
3060
3084
|
return left.replaceAll("-", "_") === right.replaceAll("-", "_");
|
|
3061
3085
|
}
|
|
3062
3086
|
/**
|
|
@@ -3078,24 +3102,30 @@ function freeAsidePath(genDirectory, found) {
|
|
|
3078
3102
|
return candidate;
|
|
3079
3103
|
}
|
|
3080
3104
|
/**
|
|
3081
|
-
* Moves a `gen/android` tree aside when it was initialised for another app id,
|
|
3082
|
-
* `tauri android init` writes a fresh one. The tree is renamed, never deleted:
|
|
3083
|
-
* keystore or hand edits. A tree whose id cannot be read is left to the
|
|
3105
|
+
* Moves a `gen/android` or `gen/apple` tree aside when it was initialised for another app id,
|
|
3106
|
+
* so the next `tauri android|ios init` writes a fresh one. The tree is renamed, never deleted:
|
|
3107
|
+
* it may hold a keystore or hand edits. A tree whose id cannot be read is left to the
|
|
3108
|
+
* completeness gate.
|
|
3084
3109
|
*
|
|
3085
3110
|
* @param options - The check options.
|
|
3086
|
-
* @param options.
|
|
3111
|
+
* @param options.target - The mobile platform the tree belongs to.
|
|
3112
|
+
* @param options.genDirectory - The absolute `src-tauri/gen/<platform>` directory.
|
|
3087
3113
|
* @param options.identifier - The configured `app.identifier`.
|
|
3088
3114
|
* @returns What was found and where it went, or undefined when the tree was kept.
|
|
3089
3115
|
* @example
|
|
3090
3116
|
* ```ts
|
|
3091
|
-
* await
|
|
3117
|
+
* await setAsideStaleMobileTree({
|
|
3118
|
+
* target: "android",
|
|
3119
|
+
* genDirectory,
|
|
3120
|
+
* identifier: "studio.kitto.memorymissing"
|
|
3121
|
+
* });
|
|
3092
3122
|
* // { found: "com.mokulabs.memorymissing", expected: "studio.kitto.memorymissing",
|
|
3093
3123
|
* // movedTo: ".../gen/android.old-com.mokulabs.memorymissing" }
|
|
3094
3124
|
* ```
|
|
3095
3125
|
*/
|
|
3096
|
-
async function
|
|
3097
|
-
const found = readAndroidApplicationId(options.genDirectory);
|
|
3098
|
-
if (found === void 0 ||
|
|
3126
|
+
async function setAsideStaleMobileTree(options) {
|
|
3127
|
+
const found = options.target === "android" ? readAndroidApplicationId(options.genDirectory) : readAppleBundleIdentifier(options.genDirectory);
|
|
3128
|
+
if (found === void 0 || sameAppId(found, options.identifier)) return void 0;
|
|
3099
3129
|
const movedTo = freeAsidePath(options.genDirectory, found);
|
|
3100
3130
|
await rename(options.genDirectory, movedTo);
|
|
3101
3131
|
return {
|
|
@@ -6600,20 +6630,20 @@ function createProjectApi(ctx) {
|
|
|
6600
6630
|
*/
|
|
6601
6631
|
const checkCompleteness = (opts) => completeness(ctx.global.projectDir, opts.target);
|
|
6602
6632
|
/**
|
|
6603
|
-
* Implements {@link Api.setAsideStaleTree}:
|
|
6604
|
-
* was moved.
|
|
6633
|
+
* Implements {@link Api.setAsideStaleTree}: one plain warn line when a tree was moved.
|
|
6605
6634
|
*
|
|
6606
6635
|
* @param opts - See {@link Api.setAsideStaleTree}.
|
|
6607
6636
|
* @param opts.target - The mobile platform whose tree to check.
|
|
6608
6637
|
* @returns See {@link Api.setAsideStaleTree}.
|
|
6609
6638
|
*/
|
|
6610
6639
|
const runSetAsideStaleTree = async (opts) => {
|
|
6611
|
-
|
|
6612
|
-
const aside = await
|
|
6613
|
-
|
|
6640
|
+
const genDirectory = genDirectoryPath(ctx.global.projectDir, opts.target);
|
|
6641
|
+
const aside = await setAsideStaleMobileTree({
|
|
6642
|
+
target: opts.target,
|
|
6643
|
+
genDirectory,
|
|
6614
6644
|
identifier: ctx.global.app.identifier
|
|
6615
6645
|
});
|
|
6616
|
-
if (aside !== void 0) ctx.log.warn(`gen
|
|
6646
|
+
if (aside !== void 0) ctx.log.warn(`gen/${path.basename(genDirectory)} was made for ${aside.found}, not ${aside.expected}: moved it to ${path.basename(aside.movedTo)} and generating it again`);
|
|
6617
6647
|
return aside;
|
|
6618
6648
|
};
|
|
6619
6649
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moku-labs/native",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
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",
|