chore: add TWA (Android) wrapper project
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
const path = require("path");
|
||||
const {
|
||||
TwaManifest,
|
||||
TwaGenerator,
|
||||
KeyTool,
|
||||
JdkHelper,
|
||||
AndroidSdkTools,
|
||||
Config,
|
||||
ConsoleLog,
|
||||
} = require("@bubblewrap/core");
|
||||
|
||||
const PLACEHOLDER_DOMAIN = "app.deldel.ir";
|
||||
const PACKAGE_ID = "ir.deldel.app";
|
||||
|
||||
async function main() {
|
||||
const log = new ConsoleLog("generate");
|
||||
|
||||
const manifest = await TwaManifest.fromWebManifest(
|
||||
"http://127.0.0.1:3000/manifest.webmanifest"
|
||||
);
|
||||
|
||||
manifest.packageId = PACKAGE_ID;
|
||||
manifest.host = PLACEHOLDER_DOMAIN;
|
||||
manifest.name = "دلدل";
|
||||
manifest.launcherName = "دلدل";
|
||||
manifest.appVersionName = "1.0.0";
|
||||
manifest.appVersionCode = 1;
|
||||
manifest.signingKey = {
|
||||
path: path.join(process.cwd(), "android.keystore"),
|
||||
alias: "android",
|
||||
};
|
||||
|
||||
await manifest.saveToFile(path.join(process.cwd(), "twa-manifest.json"));
|
||||
log.info("twa-manifest.json written.");
|
||||
|
||||
const twaGenerator = new TwaGenerator();
|
||||
await twaGenerator.createTwaProject(process.cwd(), manifest, log);
|
||||
log.info("Android project generated.");
|
||||
|
||||
const config = await Config.loadConfig(
|
||||
path.join(require("os").homedir(), ".bubblewrap", "config.json")
|
||||
);
|
||||
const jdkHelper = new JdkHelper(process, config);
|
||||
const androidSdkTools = await AndroidSdkTools.create(process, config, jdkHelper, log);
|
||||
const keyTool = new KeyTool(jdkHelper, log);
|
||||
|
||||
await keyTool.createSigningKey(
|
||||
{
|
||||
path: manifest.signingKey.path,
|
||||
alias: manifest.signingKey.alias,
|
||||
fullName: "Deldel App",
|
||||
organization: "Deldel",
|
||||
organizationalUnit: "Development",
|
||||
country: "IR",
|
||||
password: "deldel1234",
|
||||
keypassword: "deldel1234",
|
||||
},
|
||||
false
|
||||
);
|
||||
log.info("Signing keystore generated at android.keystore");
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user