mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
feat(native): everything the App Store and Google Play submissions need
- iOS: microphone usage text for "Take Video", no-export-compliance flag, ExportOptions.plist for App Store Connect uploads, the unused push forwarders gone; CI builds with Xcode 26 and lints the property lists. - Android: version and signing from Gradle properties (unsigned without them), R8 with keep rules for TREK's and Capacitor's reflective classes, no Auto Backup of the session cookie, no external file provider path, template and Firebase leftovers removed, keystores and service accounts ignored, full-size adaptive icon layers with a monochrome layer; CI also builds the release APK. - native-release.yml: signed bundle to a Play testing track and archive to TestFlight, by hand or on a v* tag, behind the store environment. - Version handshake: the server reports nativeApi 1, the app refuses a server below its minimum and tolerates an app older than the offline copy. - Address screen: privacy policy link, "Try the demo" and "What is a TREK server?"; the privacy link also in the app's server settings. Three new native strings in all 27 locales. - Donation links and the notices asking for one are hidden in the app. - Store listings for "TREK Travel Planner" in client/fastlane: texts, review notes with placeholders, privacy and account deletion page drafts, the feature graphic and icon, a length and image check in CI, and a Playwright store project with the scripts that turn its captures into screenshots. - Docs: wiki/Native-Apps.md, README no longer says there is no store app.
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Checks the store listings in fastlane/ before anything is uploaded
|
||||
* (`npm run store:check`, and the metadata job in .github/workflows/native.yml):
|
||||
*
|
||||
* - every text both stores require exists and fits its limit (App Store: name and
|
||||
* subtitle 30, keywords 100, promotional text 170, description 4000; Google
|
||||
* Play: title 30, short description 80, full description 4000, changelog 500);
|
||||
* - the URL files hold one https URL each;
|
||||
* - every screenshot and listing graphic that is present has the exact size its
|
||||
* slot takes and no alpha channel, which both stores refuse.
|
||||
*
|
||||
* Plain Node, no dependencies: a PNG's size and colour type are in its header.
|
||||
*/
|
||||
import { existsSync, readdirSync, readFileSync } from 'fs';
|
||||
import { dirname, join } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const fastlane = join(dirname(fileURLToPath(import.meta.url)), '..', 'fastlane');
|
||||
const meta = join(fastlane, 'metadata');
|
||||
const problems = [];
|
||||
|
||||
/** [file, max length] the listing needs. */
|
||||
const TEXTS = [
|
||||
['en-US/name.txt', 30],
|
||||
['en-US/subtitle.txt', 30],
|
||||
['en-US/keywords.txt', 100],
|
||||
['en-US/promotional_text.txt', 170],
|
||||
['en-US/description.txt', 4000],
|
||||
['en-US/release_notes.txt', 4000],
|
||||
['android/en-US/title.txt', 30],
|
||||
['android/en-US/short_description.txt', 80],
|
||||
['android/en-US/full_description.txt', 4000],
|
||||
['android/en-US/changelogs/default.txt', 500],
|
||||
['review_information/notes.txt', 4000],
|
||||
];
|
||||
const URLS = ['en-US/support_url.txt', 'en-US/marketing_url.txt', 'en-US/privacy_url.txt'];
|
||||
|
||||
function read(rel) {
|
||||
const path = join(meta, rel);
|
||||
if (!existsSync(path)) {
|
||||
problems.push(`${rel}: missing`);
|
||||
return null;
|
||||
}
|
||||
return readFileSync(path, 'utf8').trim();
|
||||
}
|
||||
|
||||
for (const [rel, max] of TEXTS) {
|
||||
const text = read(rel);
|
||||
if (text === null) continue;
|
||||
if (!text) problems.push(`${rel}: empty`);
|
||||
// Code points, as the stores count them, not UTF-16 units.
|
||||
const length = [...text].length;
|
||||
if (length > max) problems.push(`${rel}: ${length} characters, the limit is ${max}`);
|
||||
}
|
||||
for (const rel of URLS) {
|
||||
const url = read(rel);
|
||||
if (url !== null && !/^https:\/\/\S+$/.test(url)) problems.push(`${rel}: not a single https URL`);
|
||||
}
|
||||
|
||||
/** Width, height and whether the PNG carries alpha (colour types 4 and 6), from its header. */
|
||||
function pngInfo(path) {
|
||||
const head = readFileSync(path).subarray(0, 26);
|
||||
if (head.toString('latin1', 1, 4) !== 'PNG') return null;
|
||||
return { width: head.readUInt32BE(16), height: head.readUInt32BE(20), alpha: head[25] === 4 || head[25] === 6 };
|
||||
}
|
||||
|
||||
/** [folder or file, accepted sizes] for every image slot. */
|
||||
const IMAGES = [
|
||||
[join(fastlane, 'screenshots', 'en-US'), ['1320x2868', '2064x2752']],
|
||||
[join(meta, 'android', 'en-US', 'images', 'phoneScreenshots'), ['1080x1920']],
|
||||
[join(meta, 'android', 'en-US', 'images', 'sevenInchScreenshots'), ['1620x2880']],
|
||||
[join(meta, 'android', 'en-US', 'images', 'tenInchScreenshots'), ['1920x1080']],
|
||||
[join(meta, 'android', 'en-US', 'images', 'featureGraphic.png'), ['1024x500']],
|
||||
[join(meta, 'android', 'en-US', 'images', 'icon.png'), ['512x512']],
|
||||
];
|
||||
|
||||
for (const [target, sizes] of IMAGES) {
|
||||
if (!existsSync(target)) continue;
|
||||
const files = target.endsWith('.png')
|
||||
? [target]
|
||||
: readdirSync(target)
|
||||
.filter((f) => f.endsWith('.png'))
|
||||
.map((f) => join(target, f));
|
||||
for (const file of files) {
|
||||
const info = pngInfo(file);
|
||||
const rel = file.slice(fastlane.length + 1);
|
||||
if (!info) {
|
||||
problems.push(`${rel}: not a PNG`);
|
||||
continue;
|
||||
}
|
||||
if (!sizes.includes(`${info.width}x${info.height}`)) {
|
||||
problems.push(`${rel}: ${info.width}x${info.height}, expected ${sizes.join(' or ')}`);
|
||||
}
|
||||
if (info.alpha) problems.push(`${rel}: has an alpha channel`);
|
||||
}
|
||||
}
|
||||
|
||||
if (problems.length) {
|
||||
for (const problem of problems) console.error(`FAIL ${problem}`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('store metadata: every text fits, every image has its size and no alpha');
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Writes the Android adaptive icon layers at their full size, after
|
||||
* `npx @capacitor/assets generate` (see the icons:app script).
|
||||
*
|
||||
* The assets tool renders the foreground and background layers at the legacy
|
||||
* launcher size (192 px at xxxhdpi), while an adaptive icon layer is 108 dp
|
||||
* (432 px at xxxhdpi), so launchers that draw the icon large showed it soft.
|
||||
* The layers come from the same sources in assets/, and
|
||||
* mipmap-anydpi-v26/ic_launcher*.xml keeps placing them as before; it also uses
|
||||
* the foreground as the monochrome layer for themed icons, since the mark is
|
||||
* white on transparent.
|
||||
*/
|
||||
import { dirname, join } from 'path';
|
||||
import sharp from 'sharp';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const clientDir = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const resDir = join(clientDir, 'android', 'app', 'src', 'main', 'res');
|
||||
|
||||
/** 108 dp in pixels for each density bucket. */
|
||||
const DENSITIES = { ldpi: 81, mdpi: 108, hdpi: 162, xhdpi: 216, xxhdpi: 324, xxxhdpi: 432 };
|
||||
const LAYERS = { ic_launcher_foreground: 'icon-foreground.png', ic_launcher_background: 'icon-background.png' };
|
||||
|
||||
for (const [density, size] of Object.entries(DENSITIES)) {
|
||||
for (const [name, source] of Object.entries(LAYERS)) {
|
||||
const out = join(resDir, `mipmap-${density}`, `${name}.png`);
|
||||
await sharp(join(clientDir, 'assets', source))
|
||||
.resize(size, size)
|
||||
.png({ compressionLevel: 9 })
|
||||
.toFile(out);
|
||||
console.log(`wrote ${out}`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* The Google Play listing graphics (`npm run store:graphic`):
|
||||
*
|
||||
* featureGraphic.png 1024 x 500, the dark app background, the white TREK mark,
|
||||
* the name and the subtitle, and on the right a crop of the
|
||||
* first phone screenshot when one has been promoted
|
||||
* (`npm run store:promote`); without it, mark and text only.
|
||||
* icon.png 512 x 512, from the same 1024 px tile as the app icon.
|
||||
*
|
||||
* Both are flattened: Play refuses an alpha channel in either.
|
||||
*/
|
||||
import { existsSync, mkdirSync, readFileSync } from 'fs';
|
||||
import { dirname, join } from 'path';
|
||||
import sharp from 'sharp';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const clientDir = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const imagesDir = join(clientDir, 'fastlane', 'metadata', 'android', 'en-US', 'images');
|
||||
mkdirSync(imagesDir, { recursive: true });
|
||||
|
||||
const WIDTH = 1024;
|
||||
const HEIGHT = 500;
|
||||
const BACKGROUND = '#09090b';
|
||||
const TITLE = 'TREK Travel Planner';
|
||||
const SUBTITLE = readFileSync(join(clientDir, 'fastlane', 'metadata', 'en-US', 'subtitle.txt'), 'utf8').trim();
|
||||
|
||||
const escapeXml = (text) => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
|
||||
const mark = await sharp(join(clientDir, 'public', 'icons', 'icon-white.svg'))
|
||||
.resize(120, 120)
|
||||
.png()
|
||||
.toBuffer();
|
||||
|
||||
const text = Buffer.from(`<svg xmlns="http://www.w3.org/2000/svg" width="${WIDTH}" height="${HEIGHT}">
|
||||
<text x="72" y="300" fill="#fafafa" font-family="Helvetica, Arial, sans-serif" font-size="52" font-weight="700">${escapeXml(TITLE)}</text>
|
||||
<text x="72" y="352" fill="#a1a1aa" font-family="Helvetica, Arial, sans-serif" font-size="28">${escapeXml(SUBTITLE)}</text>
|
||||
</svg>`);
|
||||
|
||||
const layers = [
|
||||
{ input: mark, left: 72, top: 110 },
|
||||
{ input: text, left: 0, top: 0 },
|
||||
];
|
||||
|
||||
// The first phone screenshot, cut to the top of the screen and set at the right edge.
|
||||
const phone = join(imagesDir, 'phoneScreenshots', '1_dashboard.png');
|
||||
if (existsSync(phone)) {
|
||||
const crop = await sharp(phone)
|
||||
.resize({ width: 300 })
|
||||
.extract({ left: 0, top: 0, width: 300, height: 440 })
|
||||
.png()
|
||||
.toBuffer();
|
||||
const frame = Buffer.from(`<svg xmlns="http://www.w3.org/2000/svg" width="300" height="440">
|
||||
<rect width="300" height="440" rx="28" ry="28" fill="#fff"/></svg>`);
|
||||
const rounded = await sharp(crop)
|
||||
.composite([{ input: frame, blend: 'dest-in' }])
|
||||
.png()
|
||||
.toBuffer();
|
||||
layers.push({ input: rounded, left: WIDTH - 300 - 64, top: 30 });
|
||||
}
|
||||
|
||||
await sharp({ create: { width: WIDTH, height: HEIGHT, channels: 3, background: BACKGROUND } })
|
||||
.composite(layers)
|
||||
.flatten({ background: BACKGROUND })
|
||||
.removeAlpha()
|
||||
.png()
|
||||
.toFile(join(imagesDir, 'featureGraphic.png'));
|
||||
|
||||
await sharp(join(clientDir, 'assets', 'icon-only.png'))
|
||||
.resize(512, 512)
|
||||
.flatten({ background: BACKGROUND })
|
||||
.removeAlpha()
|
||||
.png()
|
||||
.toFile(join(imagesDir, 'icon.png'));
|
||||
|
||||
console.log(`wrote ${join(imagesDir, 'featureGraphic.png')} and icon.png`);
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Moves the store screenshots from e2e/.tmp/store/ (written by the Playwright
|
||||
* `store` project, `npm run store:shots`) into the folders fastlane uploads
|
||||
* from, flattened onto the app background: both stores refuse an image with an
|
||||
* alpha channel.
|
||||
*
|
||||
* iphone69, ipad13 fastlane/screenshots/en-US/ (deliver, App Store)
|
||||
* play-phone fastlane/metadata/android/en-US/images/phoneScreenshots/
|
||||
* play-7in .../sevenInchScreenshots/
|
||||
* play-10in .../tenInchScreenshots/ (supply, Google Play)
|
||||
*
|
||||
* Every image is checked against the size its device must have, so a capture at
|
||||
* the wrong viewport never reaches a listing. `npm run store:check` checks the
|
||||
* committed files the same way.
|
||||
*/
|
||||
import { existsSync, mkdirSync, readdirSync } from 'fs';
|
||||
import { dirname, join } from 'path';
|
||||
import sharp from 'sharp';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const clientDir = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const rawDir = join(clientDir, 'e2e', '.tmp', 'store');
|
||||
const fastlane = join(clientDir, 'fastlane');
|
||||
const playImages = join(fastlane, 'metadata', 'android', 'en-US', 'images');
|
||||
|
||||
const TARGETS = {
|
||||
iphone69: { dir: join(fastlane, 'screenshots', 'en-US'), size: [1320, 2868] },
|
||||
ipad13: { dir: join(fastlane, 'screenshots', 'en-US'), size: [2064, 2752] },
|
||||
'play-phone': { dir: join(playImages, 'phoneScreenshots'), size: [1080, 1920] },
|
||||
'play-7in': { dir: join(playImages, 'sevenInchScreenshots'), size: [1620, 2880] },
|
||||
'play-10in': { dir: join(playImages, 'tenInchScreenshots'), size: [1920, 1080] },
|
||||
};
|
||||
|
||||
const BACKGROUND = '#09090b';
|
||||
|
||||
if (!existsSync(rawDir)) {
|
||||
console.error(`No captures in ${rawDir}. Run npm run store:shots first.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let failed = false;
|
||||
for (const [device, { dir, size }] of Object.entries(TARGETS)) {
|
||||
const from = join(rawDir, device);
|
||||
if (!existsSync(from)) {
|
||||
console.error(`missing captures for ${device}`);
|
||||
failed = true;
|
||||
continue;
|
||||
}
|
||||
mkdirSync(dir, { recursive: true });
|
||||
for (const file of readdirSync(from).filter((f) => f.endsWith('.png'))) {
|
||||
const image = sharp(join(from, file));
|
||||
const { width, height } = await image.metadata();
|
||||
if (width !== size[0] || height !== size[1]) {
|
||||
console.error(`${device}/${file}: ${width}x${height}, expected ${size[0]}x${size[1]}`);
|
||||
failed = true;
|
||||
continue;
|
||||
}
|
||||
// The App Store folder holds both devices; the prefix keeps them apart.
|
||||
const name = dir.endsWith(join('screenshots', 'en-US')) ? `${device}_${file}` : file;
|
||||
await image.flatten({ background: BACKGROUND }).removeAlpha().png().toFile(join(dir, name));
|
||||
console.log(`wrote ${join(dir, name)}`);
|
||||
}
|
||||
}
|
||||
process.exit(failed ? 1 : 0);
|
||||
Reference in New Issue
Block a user