Initial commit

Generated by create-expo-module 56.0.3.
This commit is contained in:
2026-06-21 12:06:37 +02:00
commit edb1d5fe82
45 changed files with 21561 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env node
const { spawnSyncWithAutoShell } = require('./util');
const fs = require('fs');
const path = require('path');
const SUBTARGETS = ['plugin', 'cli', 'utils', 'scripts'];
const args = process.argv.slice(2);
const target = args[0];
let tscArgs;
if (SUBTARGETS.includes(target)) {
const targetDir = path.join(process.cwd(), target);
if (!fs.existsSync(path.join(targetDir, 'tsconfig.json'))) {
console.log(`tsconfig.json not found in ${target}, skipping build for ${target}`);
process.exit(0);
}
tscArgs = ['--build', targetDir, ...args.slice(1)];
} else {
tscArgs = [...args];
}
if (
process.stdout.isTTY &&
!process.env.CI &&
!process.env.EXPO_NONINTERACTIVE &&
!tscArgs.includes('--watch')
) {
tscArgs.push('--watch');
}
const result = spawnSyncWithAutoShell('tsc', tscArgs, { stdio: 'inherit' });
process.exit(result.status ?? 0);
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const SUBTARGETS = ['plugin', 'cli', 'utils', 'scripts'];
const target = process.argv[2];
if (target && SUBTARGETS.includes(target)) {
fs.rmSync(path.join(process.cwd(), target, 'build'), { recursive: true, force: true });
} else {
fs.rmSync(path.join(process.cwd(), 'build'), { recursive: true, force: true });
}
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/env node
const { spawn, spawnSync } = require('child_process');
const path = require('path');
const fs = require('fs');
const os = require('os');
const projectPath = path.join(process.cwd(), 'example', 'android');
function openApp(command, args, options = {}) {
const detached = options.detached ?? true;
const child = spawn(command, args, {
detached,
stdio: options.stdio ?? 'ignore',
});
child.once('error', (error) => {
console.error(`Error: Failed to open Android Studio: ${error.message}`);
process.exit(1);
});
child.once('spawn', () => {
if (detached) {
child.unref();
}
});
}
switch (process.platform) {
case 'darwin':
// Open command sends an AppleEvent to launch the app and then exits immediately, so we can inherit the stdio.
openApp('open', ['-a', 'Android Studio', projectPath], {
detached: false,
stdio: 'inherit',
});
break;
case 'linux': {
const home = os.homedir();
let studioSh;
if (process.env.ANDROID_STUDIO) {
studioSh = path.join(process.env.ANDROID_STUDIO, 'bin', 'studio.sh');
if (!fs.existsSync(studioSh)) {
console.error(
`Error: Android Studio not found at ${studioSh}.\n` +
`Check that the ANDROID_STUDIO environment variable points to your Android Studio installation directory, ` +
`or open the project manually in Android Studio: ${projectPath}`
);
process.exit(1);
}
} else {
const possiblePaths = [
// Tarball install in home directory
`${home}/android-studio/bin/studio.sh`,
// Common system-wide installs
'/opt/android-studio/bin/studio.sh',
'/usr/local/android-studio/bin/studio.sh',
// snap
'/snap/android-studio/current/bin/studio.sh',
// TODO @behenate Install toolbox on Linux and check which is the correct path
// JetBrains Toolbox 2.x (flat layout)
`${home}/.local/share/JetBrains/Toolbox/apps/android-studio/bin/studio.sh`,
// JetBrains Toolbox 2.x (with channel subdirectory still present)
`${home}/.local/share/JetBrains/Toolbox/apps/android-studio/ch-0/bin/studio.sh`,
// Flatpak (user install)
`${home}/.local/share/flatpak/app/com.google.AndroidStudio/current/active/files/extra/android-studio/bin/studio.sh`,
// Flatpak (system install)
'/var/lib/flatpak/app/com.google.AndroidStudio/current/active/files/extra/android-studio/bin/studio.sh',
];
studioSh = possiblePaths.find((p) => fs.existsSync(p));
if (!studioSh) {
for (const bin of ['studio.sh', 'android-studio', 'studio']) {
for (const lookup of [
['which', bin],
['sh', '-c', `command -v ${bin}`],
]) {
const r = spawnSync(lookup[0], lookup.slice(1), { encoding: 'utf8' });
if (r.status === 0 && r.stdout.trim()) {
studioSh = r.stdout.trim();
break;
}
}
if (studioSh) break;
}
}
if (!studioSh) {
console.error(
`Error: Android Studio not found.\n` +
`Set the ANDROID_STUDIO environment variable to your Android Studio installation directory, ` +
`or open the project manually in Android Studio: ${projectPath}`
);
process.exit(1);
}
}
// On Linux we launch Android Studio directly (long-running process), so don't inherit stdio
openApp(studioSh, [projectPath]);
break;
}
case 'win32': {
const studioExe = process.env.ANDROID_STUDIO
? path.join(process.env.ANDROID_STUDIO, 'bin', 'studio64.exe')
: path.join('C:', 'Program Files', 'Android', 'Android Studio', 'bin', 'studio64.exe');
if (!require('fs').existsSync(studioExe)) {
console.error(
`Error: Android Studio not found at ${studioExe}.\n` +
`Set the ANDROID_STUDIO environment variable to your Android Studio installation directory, ` +
`or open the project manually in Android Studio: ${projectPath}`
);
process.exit(1);
}
// On Windows we launch Android Studio directly (long-running process), so don't inherit stdio
openApp(studioExe, [projectPath]);
break;
}
default:
console.error(`Error: Unsupported platform: ${process.platform}`);
process.exit(1);
}
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env node
const { spawn } = require('child_process');
const path = require('path');
if (process.platform !== 'darwin') {
console.error(
`Error: Xcode is only available on macOS. Cannot open the iOS project on ${process.platform}.`
);
process.exit(1);
}
const projectPath = path.join(process.cwd(), 'example', 'ios');
const child = spawn('xed', [projectPath], { stdio: 'inherit' });
child.once('error', (error) => {
console.error(`Error: Failed to open Xcode: ${error.message}`);
process.exit(1);
});
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env node
const { spawnSyncWithAutoShell } = require('./util');
const fs = require('fs');
const path = require('path');
const SUBTARGETS = ['plugin', 'cli', 'utils', 'scripts'];
function run(cmd, args = []) {
const result = spawnSyncWithAutoShell(cmd, args, { stdio: 'inherit' });
if (result.status !== 0) process.exit(result.status ?? 1);
}
// Clean and build main
fs.rmSync(path.join(process.cwd(), 'build'), { recursive: true, force: true });
run('tsc');
// Clean and build any existing subtargets
for (const target of SUBTARGETS) {
const targetDir = path.join(process.cwd(), target);
if (fs.existsSync(targetDir) && fs.existsSync(path.join(targetDir, 'tsconfig.json'))) {
console.log(`Building ${target}`);
fs.rmSync(path.join(targetDir, 'build'), { recursive: true, force: true });
run('tsc', ['--build', targetDir]);
}
}
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env node
const { spawnSyncWithAutoShell } = require('./util');
const fs = require('fs');
const path = require('path');
const SUBTARGETS = ['plugin', 'cli', 'utils', 'scripts'];
let args = process.argv.slice(2);
// If the command is used like `yarn test plugin`, set the --rootDir option to the `plugin` directory
if (SUBTARGETS.includes(args[0])) {
const target = args[0];
const targetDir = path.join(process.cwd(), target);
const restArgs = args.slice(1);
args = ['--rootDir', target];
if (fs.existsSync(path.join(targetDir, 'jest.config.js'))) {
args.push('--config', `${target}/jest.config.js`);
}
args.push(...restArgs);
}
if (
process.stdout.isTTY &&
!process.env.CI &&
!process.env.EXPO_NONINTERACTIVE &&
!args.includes('--watch')
) {
args.push('--watch');
}
const result = spawnSyncWithAutoShell('jest', args, { stdio: 'inherit' });
process.exit(result.status ?? 0);
+10
View File
@@ -0,0 +1,10 @@
const { spawnSync } = require('child_process');
// On Windows, executables like `tsc` and `jest` are `.cmd` batch files and cannot be
// spawned directly — they require shell: true to resolve. On Unix, shell: true is
// unnecessary.
function spawnSyncWithAutoShell(command, args, options) {
return spawnSync(command, args, { ...options, shell: process.platform === 'win32' });
}
module.exports = { spawnSyncWithAutoShell };