-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added script to build test examples
- Loading branch information
Showing
11 changed files
with
966 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* eslint-disable no-console */ | ||
|
||
const { spawn } = require("child_process"); | ||
|
||
const DIR = "examples"; | ||
const TMP = "tmp"; | ||
const CORDOVA1 = "cordova1"; | ||
const PHONEGAP1 = "phonegap1"; | ||
const IONIC1 = "ionic1"; | ||
const IONIC3 = "ionic3"; | ||
|
||
// promisfy bash execution with stout streaming | ||
const run = (args, dir = undefined) => | ||
new Promise(resolve => { | ||
const command = args.split(" "); | ||
const output = spawn(command.shift(), command, { cwd: dir }); | ||
let stdout = ""; | ||
output.stdout.on("data", data => { | ||
stdout += String(data); | ||
console.log(String(data)); | ||
}); | ||
|
||
output.stderr.on("data", data => { | ||
throw new Error(String(data)); | ||
}); | ||
output.on("close", () => resolve(stdout.trim())); | ||
}); | ||
|
||
const cleanDirectory = async () => { | ||
await run(`rm -rf ${TMP}`); | ||
await run(`rm -rf ${DIR}`); | ||
await run(`mkdir ${DIR}`); | ||
}; | ||
|
||
const buildCordova1 = async () => { | ||
await run(`cordova create ${CORDOVA1}`, `${DIR}`); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${CORDOVA1}/index.xml ./${DIR}/${CORDOVA1}/config.xml` | ||
); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${CORDOVA1}/index.js ./${DIR}/${CORDOVA1}/www/js/index.js` | ||
); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${CORDOVA1}/index.html ./${DIR}/${CORDOVA1}/www/index.html` | ||
); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${CORDOVA1}/index.css ./${DIR}/${CORDOVA1}/www/css/index.css` | ||
); | ||
|
||
await run(`cordova plugin add ../../${TMP}`, `${DIR}/${CORDOVA1}`); | ||
await run(`cordova platform add ios android`, `${DIR}/${CORDOVA1}`); | ||
// cd examples/cordova1 | ||
// (plug in devices) | ||
// cordova run ios | ||
// cordova run android | ||
}; | ||
|
||
const buildPhoneGap1 = async () => { | ||
await run(`phonegap create phonegap1`, `${DIR}`); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${PHONEGAP1}/index.xml ./${DIR}/${PHONEGAP1}/config.xml` | ||
); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${CORDOVA1}/index.js ./${DIR}/${PHONEGAP1}/www/js/index.js` | ||
); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${CORDOVA1}/index.html ./${DIR}/${PHONEGAP1}/www/index.html` | ||
); | ||
await run( | ||
`cp ./src/scripts/examples/templates/${CORDOVA1}/index.css ./${DIR}/${PHONEGAP1}/www/css/index.css` | ||
); | ||
|
||
await run(`phonegap plugin add ../../${TMP}`, `${DIR}/${PHONEGAP1}`); | ||
await run(`phonegap platform add ios android`, `${DIR}/${PHONEGAP1}`); | ||
// cd examples/phonegap1 | ||
// (plug in devices) | ||
// phonegap run ios | ||
// phonegap run android | ||
}; | ||
|
||
const buildIonic1 = async () => { | ||
await run(`ionic start ionic1 blank --cordova --type ionic1`, `${DIR}`); | ||
await run(`ionic cordova plugin add ../../${TMP}`, `${DIR}/${IONIC1}`); | ||
await run(`ionic cordova platform add ios android`, `${DIR}/${IONIC1}`); | ||
}; | ||
|
||
const buildIonic3 = async () => { | ||
await run(`ionic start ionic3 blank --cordova`, `${DIR}`); | ||
await run(`ionic cordova plugin add ../../${TMP}`, `${DIR}/${IONIC3}`); | ||
await run(`ionic cordova platform add ios android`, `${DIR}/${IONIC3}`); | ||
}; | ||
|
||
const installDependencies = async () => { | ||
await run("yarn add -g cordova ionic phonegap"); | ||
}; | ||
|
||
const copySdk = async () => { | ||
await run( | ||
`rsync -a ./ ./${TMP} --exclude testbed --exclude node_modules --exclude .git --exclude ${DIR} --exclude ${TMP}` | ||
); | ||
}; | ||
|
||
const removeCopySdk = async () => { | ||
await run(`rm -rf ./${TMP}`); | ||
}; | ||
|
||
const main = async () => { | ||
await cleanDirectory(); | ||
// await installDependencies(); | ||
await copySdk(); | ||
// await buildCordova1(); | ||
await buildPhoneGap1(); | ||
// await buildIonic1(); | ||
// await buildIonic3(); | ||
await removeCopySdk(); | ||
}; | ||
|
||
module.exports = main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
* { | ||
color: #303030; | ||
box-sizing: border-box; | ||
background-color: #ffffff !important; | ||
} | ||
body { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 1em 0em 0.5em 0em; | ||
max-width: 40em; | ||
margin: 0 auto; | ||
} | ||
fieldset { | ||
border-color: #303030; | ||
margin: 0.5em 1em; | ||
padding: 0.75em; | ||
} | ||
fieldset > *:not(:first-child) { | ||
margin-bottom: 0.5em; | ||
} | ||
fieldset > *:last-child { | ||
margin-bottom: 0; | ||
} | ||
section { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
section > button:nth-child(even) { | ||
margin-left: 0.5em; | ||
} | ||
section > button:nth-child(odd) { | ||
margin-right: 0.5em; | ||
} | ||
button, | ||
input { | ||
padding: 0.5em; | ||
border: 3px solid #f5f5f5; | ||
width: 100%; | ||
} | ||
button { | ||
background-color: #f5f5f5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;"> | ||
<meta name="format-detection" content="telephone=no"> | ||
<meta name="msapplication-tap-highlight" content="no"> | ||
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="css/index.css"> | ||
<title>Branch Testing</title> | ||
</head> | ||
<body> | ||
<fieldset> | ||
<legend>Branch Universal Object</legend> | ||
<button id="branchUniversalObject">Create</button> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Branch Deep Link</legend> | ||
<input id="alias" name="alias" type="text" placeholder="Deep link alias (optional)"> | ||
<section> | ||
<button id="branchDeepLink">Create</button> | ||
<button id="branchShareSheet">Share</button> | ||
</section> | ||
<input type="text" id="generated-url" placeholder="Deep link" readonly> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Branch Deep Link Data</legend> | ||
<section> | ||
<button id="branchFirstData">First</button> | ||
<button id="branchLatestData">Latest</button> | ||
</section> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Branch Content</legend> | ||
<section> | ||
<button id="branchView">Create</button> | ||
<button id="branchSpotlight">Share</button> | ||
</section> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Branch User</legend> | ||
<input type="text" id="identity" name="identity" placeholder="User Id"> | ||
<section> | ||
<button id="branchUser">Login</button> | ||
<button id="branchLogout">Logout</button> | ||
</section> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Branch Event</legend> | ||
<input type="text" id="custom-action" name="custom-action" placeholder="Event Name"> | ||
<section> | ||
<button id="branchEvent">Create</button> | ||
<button id="branchCommerce">Commerce</button> | ||
</section> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Branch Referral</legend> | ||
<section> | ||
<button id="branchReferralsReward">Reward</button> | ||
<button id="branchReferralsLoad">Load</button> | ||
</section> | ||
<section> | ||
<button id="branchReferralsRedeem">Redeem</button> | ||
<button id="branchReferralsHistory">History</button> | ||
</section> | ||
</fieldset> | ||
<script type="text/javascript" src="cordova.js"></script> | ||
<script type="text/javascript" src="js/index.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.