flaunt-your-app 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +31 -3
- package/bin/flaunt.mjs +558 -0
- package/lib/build.mjs +128 -0
- package/lib/files.mjs +83 -0
- package/lib/github.mjs +115 -0
- package/lib/pwa.mjs +137 -0
- package/lib/workflow.d.mts +9 -0
- package/lib/workflow.mjs +77 -0
- package/package.json +32 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shubham Shetmandrekar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# flaunt-your-app
|
|
2
|
+
|
|
3
|
+
Host mobile apps like websites, for free. Deploy the web version of an Expo / React Native, Flutter,
|
|
4
|
+
Ionic or PWA app to `https://<app>.flaunt-your-app.workers.dev`: a link that opens on any phone and
|
|
5
|
+
installs to the home screen.
|
|
6
|
+
|
|
7
|
+
## Deploy on every push
|
|
8
|
+
|
|
9
|
+
In your app's folder:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npx flaunt-your-app init
|
|
13
|
+
git add .github/workflows/flaunt.yml && git commit -m "Deploy to Flaunt Your App" && git push
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Pushes to your main branch update the app. Pull requests get a comment with a preview link and a QR
|
|
17
|
+
code. No account, tokens or secrets: GitHub Actions proves which repository the deploy comes from.
|
|
18
|
+
|
|
19
|
+
Or set it up in the browser: <https://www.flaunt-your-app.workers.dev/new>
|
|
20
|
+
|
|
21
|
+
## Deploy from your terminal
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npx flaunt-your-app login # sign in with GitHub, once
|
|
25
|
+
npx flaunt-your-app deploy --build # build for the web and deploy
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`--build` detects Flutter, Expo, Ionic/Vite/any `build` script, or plain HTML, and uses npm, pnpm,
|
|
29
|
+
yarn or bun to match your lockfile. Run `npx flaunt-your-app --help` for every command.
|
|
30
|
+
|
|
31
|
+
Needs Node.js 22 or newer.
|
package/bin/flaunt.mjs
ADDED
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Flaunt Your App CLI: deploy a mobile web build (Expo web, Flutter web, Ionic, any PWA)
|
|
3
|
+
// to a Flaunt Your App platform. No dependencies; needs Node 22+.
|
|
4
|
+
|
|
5
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { parseArgs } from "node:util";
|
|
11
|
+
import { detectBuild, run } from "../lib/build.mjs";
|
|
12
|
+
import { assetHash, collectFiles, contentTypeFor } from "../lib/files.mjs";
|
|
13
|
+
import {
|
|
14
|
+
actionsContext,
|
|
15
|
+
commentOnPullRequest,
|
|
16
|
+
deployMarkdown,
|
|
17
|
+
githubRepo,
|
|
18
|
+
requestIdToken,
|
|
19
|
+
writeJobSummary,
|
|
20
|
+
} from "../lib/github.mjs";
|
|
21
|
+
import { addPwaSupport } from "../lib/pwa.mjs";
|
|
22
|
+
import { DEFAULT_PLATFORM_URL, WORKFLOW_PATH, workflowYaml } from "../lib/workflow.mjs";
|
|
23
|
+
|
|
24
|
+
const DEFAULT_API = process.env.FLAUNT_API || DEFAULT_PLATFORM_URL;
|
|
25
|
+
const CREDENTIALS_FILE = path.join(os.homedir(), ".flaunt", "credentials.json");
|
|
26
|
+
const UPLOAD_CONCURRENCY = 3;
|
|
27
|
+
/** GitHub's OIDC tokens are short-lived; fetch a fresh one for long uploads. */
|
|
28
|
+
const ID_TOKEN_MAX_AGE_MS = 4 * 60 * 1000;
|
|
29
|
+
|
|
30
|
+
/** Where common mobile frameworks put their web build, in the order we look. */
|
|
31
|
+
const OUTPUT_DIRS = [
|
|
32
|
+
["dist", "Expo / Vite"],
|
|
33
|
+
["build/web", "Flutter"],
|
|
34
|
+
["www", "Ionic / Capacitor"],
|
|
35
|
+
["build", "Create React App"],
|
|
36
|
+
["out", "Next.js static export"],
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const PROJECT_NAME = /^(?!.*--)[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/;
|
|
40
|
+
|
|
41
|
+
const HELP = `flaunt: host mobile web apps on their own URL
|
|
42
|
+
|
|
43
|
+
Deploy on every push (recommended)
|
|
44
|
+
flaunt init [--name <project>] Add a GitHub Actions workflow to this repo, then push.
|
|
45
|
+
Pushes to the main branch update the app; pull requests
|
|
46
|
+
get a preview link and QR code. No tokens or secrets.
|
|
47
|
+
|
|
48
|
+
Deploy from this computer
|
|
49
|
+
flaunt login Sign in with GitHub (once)
|
|
50
|
+
flaunt deploy [dir] [options] Upload a build and put it live
|
|
51
|
+
flaunt list <project> Show a project's deployments
|
|
52
|
+
flaunt promote <project> <id> Point production at a deployment (rollback)
|
|
53
|
+
flaunt whoami Show who you're signed in as, and your apps
|
|
54
|
+
flaunt logout Sign out
|
|
55
|
+
|
|
56
|
+
Deploy options
|
|
57
|
+
--build Install dependencies and build the app first (Expo, Flutter, Ionic, Vite…)
|
|
58
|
+
--build-command <cmd> Build with this command instead of the detected one
|
|
59
|
+
--name <project> Project name (default: repo or folder name). Becomes part of the app's URL
|
|
60
|
+
--preview Deploy without changing production
|
|
61
|
+
--no-pwa Don't add a web manifest and icons to apps that lack one
|
|
62
|
+
--api <url> Flaunt Your App platform (default: $FLAUNT_API or ${DEFAULT_API})
|
|
63
|
+
|
|
64
|
+
If [dir] is omitted, flaunt looks for ${OUTPUT_DIRS.map(([d]) => d).join(", ")}.`;
|
|
65
|
+
|
|
66
|
+
async function main() {
|
|
67
|
+
const { values, positionals } = parseArgs({
|
|
68
|
+
allowPositionals: true,
|
|
69
|
+
options: {
|
|
70
|
+
name: { type: "string" },
|
|
71
|
+
api: { type: "string" },
|
|
72
|
+
branch: { type: "string" },
|
|
73
|
+
build: { type: "boolean", default: false },
|
|
74
|
+
"build-command": { type: "string" },
|
|
75
|
+
preview: { type: "boolean", default: false },
|
|
76
|
+
"no-pwa": { type: "boolean", default: false },
|
|
77
|
+
force: { type: "boolean", default: false },
|
|
78
|
+
help: { type: "boolean", short: "h", default: false },
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const [command, ...args] = positionals;
|
|
83
|
+
const api = (values.api || DEFAULT_API).replace(/\/+$/, "");
|
|
84
|
+
|
|
85
|
+
if (values.help || !command || command === "help") return console.log(HELP);
|
|
86
|
+
if (command === "deploy") return deploy(api, args[0], values);
|
|
87
|
+
if (command === "init") return init(api, values);
|
|
88
|
+
if (command === "login") return login(api);
|
|
89
|
+
if (command === "logout") return logout(api);
|
|
90
|
+
if (command === "whoami") return whoami(api);
|
|
91
|
+
if (command === "list" || command === "ls") return list(api, args[0]);
|
|
92
|
+
if (command === "promote" || command === "rollback") return promote(api, args[0], args[1]);
|
|
93
|
+
throw new CliError(`Unknown command "${command}". Run \`flaunt --help\`.`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// deploy
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
async function deploy(api, dirArg, options) {
|
|
101
|
+
const github = actionsContext();
|
|
102
|
+
const name = options.name ?? slugify(github?.repoName || path.basename(process.cwd()));
|
|
103
|
+
if (!PROJECT_NAME.test(name)) {
|
|
104
|
+
throw new CliError(
|
|
105
|
+
`"${name}" is not a valid project name. Use --name with 3–40 lowercase letters, digits and single hyphens.`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Sign in before a possibly long build, so problems show up straight away.
|
|
110
|
+
const auth = await authFor(api, name);
|
|
111
|
+
|
|
112
|
+
const dir = options.build ? build(dirArg, options) : resolveOutputDir(dirArg);
|
|
113
|
+
|
|
114
|
+
step(`Scanning ${path.relative(process.cwd(), dir) || "."}`);
|
|
115
|
+
let files = await collectFiles(dir);
|
|
116
|
+
if (!files.some((f) => f.path === "/index.html")) {
|
|
117
|
+
throw new CliError(`No index.html in ${dir}. Point flaunt at your web build output folder.`);
|
|
118
|
+
}
|
|
119
|
+
if (!options["no-pwa"]) {
|
|
120
|
+
const pwa = addPwaSupport(files, name);
|
|
121
|
+
files = pwa.files;
|
|
122
|
+
if (pwa.added) detail("No web manifest found: adding one with icons so the app can be installed");
|
|
123
|
+
}
|
|
124
|
+
for (const file of files) {
|
|
125
|
+
file.size = file.contents.byteLength;
|
|
126
|
+
file.hash = assetHash(file.contents, file.path);
|
|
127
|
+
}
|
|
128
|
+
const totalBytes = files.reduce((sum, f) => sum + f.size, 0);
|
|
129
|
+
detail(`${files.length} files, ${formatBytes(totalBytes)}`);
|
|
130
|
+
|
|
131
|
+
// In GitHub Actions, only the default branch updates the live app.
|
|
132
|
+
const promote = !options.preview && (github?.deploysToProduction ?? true);
|
|
133
|
+
|
|
134
|
+
step(`Creating deployment for ${name}`);
|
|
135
|
+
const deployment = await request(api, "POST", "/api/deployments", {
|
|
136
|
+
auth,
|
|
137
|
+
json: { project: name, files: files.map(({ path, hash, size }) => ({ path, hash, size })) },
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Cloudflare groups the files it doesn't have yet into buckets; each bucket is one upload request.
|
|
141
|
+
const byHash = new Map(files.map((f) => [f.hash, f]));
|
|
142
|
+
const toUpload = deployment.buckets.reduce((sum, bucket) => sum + bucket.length, 0);
|
|
143
|
+
const unchanged = new Set(files.map((f) => f.hash)).size - toUpload;
|
|
144
|
+
step(`Uploading ${toUpload} file(s)${unchanged > 0 ? ` (${unchanged} unchanged, skipped)` : ""}`);
|
|
145
|
+
|
|
146
|
+
let uploaded = 0;
|
|
147
|
+
await runConcurrently(deployment.buckets, UPLOAD_CONCURRENCY, async (bucket) => {
|
|
148
|
+
const form = new FormData();
|
|
149
|
+
for (const hash of bucket) {
|
|
150
|
+
const file = byHash.get(hash);
|
|
151
|
+
form.append(hash, new File([file.contents.toString("base64")], hash, { type: contentTypeFor(file.path) }));
|
|
152
|
+
}
|
|
153
|
+
await request(api, "POST", `/api/deployments/${deployment.id}/upload`, { auth, body: form });
|
|
154
|
+
uploaded += bucket.length;
|
|
155
|
+
if (process.stdout.isTTY) process.stdout.write(`\r ${uploaded}/${toUpload}`);
|
|
156
|
+
});
|
|
157
|
+
if (process.stdout.isTTY && toUpload) process.stdout.write("\n");
|
|
158
|
+
|
|
159
|
+
step("Publishing");
|
|
160
|
+
const result = await request(api, "POST", `/api/deployments/${deployment.id}/finalize`, {
|
|
161
|
+
auth,
|
|
162
|
+
json: { promote },
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
console.log(`\n✔ Deployed ${name} (${result.id})\n`);
|
|
166
|
+
console.log(` Deployment ${result.url}`);
|
|
167
|
+
if (result.promoted) console.log(` Production ${result.productionUrl}`);
|
|
168
|
+
console.log(` Dashboard ${result.dashboardUrl}`);
|
|
169
|
+
if (!result.promoted) {
|
|
170
|
+
console.log(
|
|
171
|
+
github && !options.preview
|
|
172
|
+
? `\n Preview only: production updates from pushes to ${github.defaultBranch ?? "the default branch"}.`
|
|
173
|
+
: `\n Not promoted. To put it live: flaunt promote ${name} ${result.id}`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (result.promoted && !promote) console.log(`\n (A project's first deploy always goes to production.)`);
|
|
177
|
+
|
|
178
|
+
if (github) await reportToGitHub(github, name, result);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Builds the app for the web and returns the folder to upload. */
|
|
182
|
+
function build(dirArg, options) {
|
|
183
|
+
const cwd = process.cwd();
|
|
184
|
+
let plan;
|
|
185
|
+
try {
|
|
186
|
+
plan = detectBuild(cwd, { buildCommand: options["build-command"] });
|
|
187
|
+
} catch (error) {
|
|
188
|
+
throw new CliError(error.message);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
step(plan.install || plan.build ? `Building ${plan.framework} app for the web` : "Plain HTML app: nothing to build");
|
|
192
|
+
for (const command of [plan.install, plan.build].filter(Boolean)) {
|
|
193
|
+
detail(`$ ${command}`);
|
|
194
|
+
try {
|
|
195
|
+
run(command, cwd);
|
|
196
|
+
} catch (error) {
|
|
197
|
+
throw new CliError(
|
|
198
|
+
plan.framework === "Expo" && command === plan.build
|
|
199
|
+
? `${error.message}\n Expo needs its web packages to build for the web: npx expo install react-dom react-native-web @expo/metro-runtime`
|
|
200
|
+
: error.message,
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (dirArg) return resolveOutputDir(dirArg);
|
|
206
|
+
if (plan.outputDir) {
|
|
207
|
+
const dir = path.resolve(plan.outputDir);
|
|
208
|
+
if (!existsSync(path.join(dir, "index.html"))) {
|
|
209
|
+
throw new CliError(`The build finished but ${plan.outputDir}/index.html doesn't exist.`);
|
|
210
|
+
}
|
|
211
|
+
return dir;
|
|
212
|
+
}
|
|
213
|
+
return resolveOutputDir();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Job summary, a notice on the run, and a comment with the preview link on pull requests. */
|
|
217
|
+
async function reportToGitHub(github, name, result) {
|
|
218
|
+
const markdown = deployMarkdown({
|
|
219
|
+
project: name,
|
|
220
|
+
result,
|
|
221
|
+
qrUrl: `${result.dashboardUrl}/qr.svg?d=${result.id}`,
|
|
222
|
+
context: github,
|
|
223
|
+
});
|
|
224
|
+
console.log(`::notice title=Deployed ${name}::${result.promoted ? result.productionUrl : result.url}`);
|
|
225
|
+
try {
|
|
226
|
+
await writeJobSummary(github, markdown);
|
|
227
|
+
} catch (error) {
|
|
228
|
+
console.log(`::warning::Couldn't write the job summary: ${error.message}`);
|
|
229
|
+
}
|
|
230
|
+
if (github.pullRequestNumber && github.token) {
|
|
231
|
+
try {
|
|
232
|
+
await commentOnPullRequest(github, name, markdown);
|
|
233
|
+
detail(`Commented the preview link on pull request #${github.pullRequestNumber}`);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.log(`::warning::Couldn't comment on the pull request: ${error.message}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ---------------------------------------------------------------------------
|
|
241
|
+
// init: deploy on every push with GitHub Actions
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
|
|
244
|
+
async function init(api, options) {
|
|
245
|
+
const cwd = process.cwd();
|
|
246
|
+
const gitRoot = git(["rev-parse", "--show-toplevel"], cwd);
|
|
247
|
+
if (!gitRoot) {
|
|
248
|
+
throw new CliError("Run `flaunt init` inside your app's git repository (and push it to GitHub).");
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let plan;
|
|
252
|
+
try {
|
|
253
|
+
plan = detectBuild(cwd);
|
|
254
|
+
} catch (error) {
|
|
255
|
+
throw new CliError(error.message);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const directory = path.relative(gitRoot, cwd).split(path.sep).join("/");
|
|
259
|
+
const repo = githubRepo(git(["remote", "get-url", "origin"], cwd));
|
|
260
|
+
const name = options.name ?? slugify(directory ? path.basename(cwd) : repo?.split("/")[1] ?? path.basename(cwd));
|
|
261
|
+
if (!PROJECT_NAME.test(name)) {
|
|
262
|
+
throw new CliError(`"${name}" can't be a project name. Pass --name with 3–40 lowercase letters, digits and hyphens.`);
|
|
263
|
+
}
|
|
264
|
+
const branch = options.branch ?? defaultBranch(cwd);
|
|
265
|
+
|
|
266
|
+
const file = path.join(gitRoot, WORKFLOW_PATH);
|
|
267
|
+
if (existsSync(file) && !options.force) {
|
|
268
|
+
throw new CliError(`${WORKFLOW_PATH} already exists. Pass --force to replace it.`);
|
|
269
|
+
}
|
|
270
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
271
|
+
await writeFile(file, workflowYaml({ project: name, branch, directory, platformUrl: api }));
|
|
272
|
+
|
|
273
|
+
console.log(`✔ Wrote ${WORKFLOW_PATH}`);
|
|
274
|
+
detail(`${plan.framework} app${directory ? ` in ${directory}/` : ""}, deployed as "${name}"`);
|
|
275
|
+
if (!repo) detail("⚠ This repository's origin isn't on GitHub. The workflow only runs on GitHub.");
|
|
276
|
+
console.log(`
|
|
277
|
+
Commit and push it:
|
|
278
|
+
|
|
279
|
+
git add ${WORKFLOW_PATH}
|
|
280
|
+
git commit -m "Deploy to Flaunt Your App"
|
|
281
|
+
git push
|
|
282
|
+
|
|
283
|
+
Every push to ${branch} then updates the app, and pull requests get a preview
|
|
284
|
+
link and QR code as a comment. Follow it at ${api}/p/${name}`);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function git(args, cwd) {
|
|
288
|
+
const result = spawnSync("git", args, { cwd, encoding: "utf8" });
|
|
289
|
+
return result.status === 0 ? result.stdout.trim() : null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function defaultBranch(cwd) {
|
|
293
|
+
const remoteHead = git(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], cwd);
|
|
294
|
+
if (remoteHead) return remoteHead.replace(/^origin\//, "");
|
|
295
|
+
return git(["branch", "--show-current"], cwd) || "main";
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ---------------------------------------------------------------------------
|
|
299
|
+
// Signing in
|
|
300
|
+
// ---------------------------------------------------------------------------
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Returns a function that yields the bearer token for API calls:
|
|
304
|
+
* FLAUNT_TOKEN → GitHub Actions OIDC → legacy project token → `flaunt login` session.
|
|
305
|
+
* Offers to sign in when none of those exist and someone is at the keyboard.
|
|
306
|
+
*/
|
|
307
|
+
async function authFor(api, project) {
|
|
308
|
+
if (process.env.FLAUNT_TOKEN) return () => process.env.FLAUNT_TOKEN;
|
|
309
|
+
|
|
310
|
+
const github = actionsContext();
|
|
311
|
+
if (github) {
|
|
312
|
+
if (!github.canRequestIdToken) {
|
|
313
|
+
throw new CliError(
|
|
314
|
+
github.eventName.startsWith("pull_request")
|
|
315
|
+
? "Pull requests from forks can't deploy: GitHub doesn't let them prove which repository they belong to."
|
|
316
|
+
: "Add `permissions: id-token: write` to the workflow, so flaunt can prove which repository it deploys from.",
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
let cached = null;
|
|
320
|
+
return async () => {
|
|
321
|
+
if (!cached || Date.now() - cached.at > ID_TOKEN_MAX_AGE_MS) {
|
|
322
|
+
cached = { token: await requestIdToken(api), at: Date.now() };
|
|
323
|
+
}
|
|
324
|
+
return cached.token;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const credentials = await loadCredentials(api);
|
|
329
|
+
if (project && credentials.tokens[project]) return () => credentials.tokens[project];
|
|
330
|
+
if (credentials.session) return () => credentials.session;
|
|
331
|
+
if (process.stdin.isTTY && process.stdout.isTTY && !process.env.CI) {
|
|
332
|
+
const session = await login(api);
|
|
333
|
+
return () => session;
|
|
334
|
+
}
|
|
335
|
+
throw new CliError("Sign in first with `flaunt login`, or deploy from GitHub Actions (`flaunt init`).");
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async function login(api) {
|
|
339
|
+
const start = await request(api, "POST", "/api/auth/device");
|
|
340
|
+
step("Sign in with GitHub");
|
|
341
|
+
console.log(`\n Open ${start.verificationUri} and enter the code:\n\n ${start.userCode}\n`);
|
|
342
|
+
openBrowser(start.verificationUri);
|
|
343
|
+
|
|
344
|
+
let interval = start.interval;
|
|
345
|
+
const deadline = Date.now() + start.expiresIn * 1000;
|
|
346
|
+
while (Date.now() < deadline) {
|
|
347
|
+
await new Promise((resolve) => setTimeout(resolve, interval * 1000));
|
|
348
|
+
const poll = await request(api, "POST", "/api/auth/device/token", { json: { deviceCode: start.deviceCode } });
|
|
349
|
+
if (poll.pending) {
|
|
350
|
+
interval = poll.interval ?? interval;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
const credentials = await loadCredentials(api);
|
|
354
|
+
await saveCredentials(api, { ...credentials, session: poll.token, login: poll.login });
|
|
355
|
+
console.log(`✔ Signed in as ${poll.login}`);
|
|
356
|
+
return poll.token;
|
|
357
|
+
}
|
|
358
|
+
throw new CliError("The sign-in code expired. Run `flaunt login` again.");
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async function logout(api) {
|
|
362
|
+
const credentials = await loadCredentials(api);
|
|
363
|
+
if (!credentials.session) return console.log("Not signed in.");
|
|
364
|
+
try {
|
|
365
|
+
await request(api, "DELETE", "/api/auth/session", { auth: credentials.session });
|
|
366
|
+
} catch {
|
|
367
|
+
// Signing out locally is what matters; the server-side session is revoked if we can reach it.
|
|
368
|
+
}
|
|
369
|
+
await saveCredentials(api, { tokens: credentials.tokens });
|
|
370
|
+
console.log(`✔ Signed out${credentials.login ? ` ${credentials.login}` : ""}`);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
async function whoami(api) {
|
|
374
|
+
const credentials = await loadCredentials(api);
|
|
375
|
+
if (!credentials.session) return console.log("Not signed in. Run `flaunt login`.");
|
|
376
|
+
const me = await request(api, "GET", "/api/auth/session", { auth: credentials.session });
|
|
377
|
+
console.log(`${me.login} on ${api}\n`);
|
|
378
|
+
if (!me.projects.length) return console.log(` No apps yet (up to ${me.appLimit}).`);
|
|
379
|
+
for (const p of me.projects) {
|
|
380
|
+
console.log(` ${p.name.padEnd(24)} ${p.url ?? "(not deployed yet)"}${p.repo ? ` ← github.com/${p.repo}` : ""}`);
|
|
381
|
+
}
|
|
382
|
+
console.log(`\n ${me.projects.length} of ${me.appLimit} apps used.`);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function openBrowser(url) {
|
|
386
|
+
if (!process.stdout.isTTY) return;
|
|
387
|
+
const [command, args] =
|
|
388
|
+
process.platform === "win32"
|
|
389
|
+
? ["cmd", ["/c", "start", "", url]]
|
|
390
|
+
: process.platform === "darwin"
|
|
391
|
+
? ["open", [url]]
|
|
392
|
+
: ["xdg-open", [url]];
|
|
393
|
+
try {
|
|
394
|
+
spawn(command, args, { stdio: "ignore", detached: true }).on("error", () => {}).unref();
|
|
395
|
+
} catch {
|
|
396
|
+
// The URL is printed anyway.
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// ---------------------------------------------------------------------------
|
|
401
|
+
// list / promote
|
|
402
|
+
// ---------------------------------------------------------------------------
|
|
403
|
+
|
|
404
|
+
async function list(api, name) {
|
|
405
|
+
if (!name) throw new CliError("Usage: flaunt list <project>");
|
|
406
|
+
const project = await request(api, "GET", `/api/projects/${encodeURIComponent(name)}`);
|
|
407
|
+
console.log(`${project.name} ${project.url ?? "(not deployed yet)"}${project.repo ? ` ← github.com/${project.repo}` : ""}\n`);
|
|
408
|
+
if (!project.deployments.length) return console.log(" No deployments yet.");
|
|
409
|
+
for (const d of project.deployments) {
|
|
410
|
+
const flag = d.production ? "● production" : d.status === "pending" ? "… uploading" : "";
|
|
411
|
+
const source = d.gitRef ? `${d.gitRef}@${d.gitSha.slice(0, 7)}` : "";
|
|
412
|
+
console.log(
|
|
413
|
+
` ${d.id} ${new Date(d.createdAt).toLocaleString().padEnd(24)} ${String(d.fileCount).padStart(5)} files ${formatBytes(d.totalBytes).padStart(9)} ${source.padEnd(20)} ${flag}`,
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
async function promote(api, name, deploymentId) {
|
|
419
|
+
if (!name || !deploymentId) throw new CliError("Usage: flaunt promote <project> <deployment-id>");
|
|
420
|
+
const auth = await authFor(api, name);
|
|
421
|
+
const result = await request(api, "POST", `/api/projects/${encodeURIComponent(name)}/promote`, {
|
|
422
|
+
auth,
|
|
423
|
+
json: { deploymentId },
|
|
424
|
+
});
|
|
425
|
+
console.log(`✔ ${result.url} now serves deployment ${result.productionDeploymentId}`);
|
|
426
|
+
console.log(" It can take up to a minute to reach every Cloudflare location.");
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// ---------------------------------------------------------------------------
|
|
430
|
+
// Build folder
|
|
431
|
+
// ---------------------------------------------------------------------------
|
|
432
|
+
|
|
433
|
+
function resolveOutputDir(dirArg) {
|
|
434
|
+
if (dirArg) {
|
|
435
|
+
const dir = path.resolve(dirArg);
|
|
436
|
+
if (!existsSync(dir)) throw new CliError(`Folder not found: ${dirArg}`);
|
|
437
|
+
return dir;
|
|
438
|
+
}
|
|
439
|
+
for (const [candidate, framework] of OUTPUT_DIRS) {
|
|
440
|
+
const dir = path.resolve(candidate);
|
|
441
|
+
if (existsSync(path.join(dir, "index.html"))) {
|
|
442
|
+
detail(`Using ./${candidate} (${framework} build output)`);
|
|
443
|
+
return dir;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
throw new CliError(
|
|
447
|
+
"Couldn't find a build folder. Run `flaunt deploy --build` to build the app first, or pass the folder: flaunt deploy ./dist",
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// ---------------------------------------------------------------------------
|
|
452
|
+
// Credentials: { "<api>": { session, login, tokens: { "<project>": "<legacy token>" } } }
|
|
453
|
+
// ---------------------------------------------------------------------------
|
|
454
|
+
|
|
455
|
+
async function readCredentialsFile() {
|
|
456
|
+
try {
|
|
457
|
+
return JSON.parse(await readFile(CREDENTIALS_FILE, "utf8"));
|
|
458
|
+
} catch {
|
|
459
|
+
return {};
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
async function loadCredentials(api) {
|
|
464
|
+
const entry = (await readCredentialsFile())[api] ?? {};
|
|
465
|
+
// Before GitHub sign-in, entries were a flat { "<project>": "<token>" } map.
|
|
466
|
+
const legacy = !("tokens" in entry) && !("session" in entry);
|
|
467
|
+
const tokens = legacy
|
|
468
|
+
? Object.fromEntries(Object.entries(entry).filter(([, value]) => typeof value === "string"))
|
|
469
|
+
: (entry.tokens ?? {});
|
|
470
|
+
return { session: legacy ? undefined : entry.session, login: legacy ? undefined : entry.login, tokens };
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
async function saveCredentials(api, credentials) {
|
|
474
|
+
const all = await readCredentialsFile();
|
|
475
|
+
all[api] = { tokens: {}, ...credentials };
|
|
476
|
+
await mkdir(path.dirname(CREDENTIALS_FILE), { recursive: true });
|
|
477
|
+
await writeFile(CREDENTIALS_FILE, JSON.stringify(all, null, 2) + "\n", { mode: 0o600 });
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// ---------------------------------------------------------------------------
|
|
481
|
+
// HTTP
|
|
482
|
+
// ---------------------------------------------------------------------------
|
|
483
|
+
|
|
484
|
+
async function request(api, method, route, { auth, json, body } = {}) {
|
|
485
|
+
const headers = {};
|
|
486
|
+
const token = typeof auth === "function" ? await auth() : auth;
|
|
487
|
+
if (token) headers.authorization = `Bearer ${token}`;
|
|
488
|
+
// FormData bodies set their own multipart content type (with boundary).
|
|
489
|
+
if (json !== undefined) headers["content-type"] = "application/json";
|
|
490
|
+
|
|
491
|
+
let response;
|
|
492
|
+
try {
|
|
493
|
+
response = await fetch(api + route, {
|
|
494
|
+
method,
|
|
495
|
+
headers,
|
|
496
|
+
body: json !== undefined ? JSON.stringify(json) : body,
|
|
497
|
+
});
|
|
498
|
+
} catch (cause) {
|
|
499
|
+
throw new CliError(`Could not reach ${api} (${cause.cause?.code ?? cause.message}). Is the platform running?`);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const text = await response.text();
|
|
503
|
+
let data;
|
|
504
|
+
try {
|
|
505
|
+
data = text ? JSON.parse(text) : {};
|
|
506
|
+
} catch {
|
|
507
|
+
data = { error: text.slice(0, 200) };
|
|
508
|
+
}
|
|
509
|
+
if (!response.ok) {
|
|
510
|
+
const error = new CliError(data.error || `${method} ${route} failed with HTTP ${response.status}`);
|
|
511
|
+
error.status = response.status;
|
|
512
|
+
throw error;
|
|
513
|
+
}
|
|
514
|
+
return data;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
async function runConcurrently(items, limit, worker) {
|
|
518
|
+
let next = 0;
|
|
519
|
+
const runners = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
520
|
+
while (next < items.length) await worker(items[next++]);
|
|
521
|
+
});
|
|
522
|
+
await Promise.all(runners);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// ---------------------------------------------------------------------------
|
|
526
|
+
// Output helpers
|
|
527
|
+
// ---------------------------------------------------------------------------
|
|
528
|
+
|
|
529
|
+
class CliError extends Error {}
|
|
530
|
+
|
|
531
|
+
function step(message) {
|
|
532
|
+
console.log(`→ ${message}`);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function detail(message) {
|
|
536
|
+
console.log(` ${message}`);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function slugify(value) {
|
|
540
|
+
return value
|
|
541
|
+
.toLowerCase()
|
|
542
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
543
|
+
.replace(/-{2,}/g, "-")
|
|
544
|
+
.replace(/^-|-$/g, "")
|
|
545
|
+
.slice(0, 40)
|
|
546
|
+
.replace(/-$/, "");
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function formatBytes(bytes) {
|
|
550
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
551
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
552
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
main().catch((error) => {
|
|
556
|
+
console.error(`\n✖ ${error instanceof CliError ? error.message : error.stack}`);
|
|
557
|
+
process.exit(1);
|
|
558
|
+
});
|
package/lib/build.mjs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Works out how to build an app for the web, so one GitHub Actions workflow
|
|
7
|
+
* (and `flaunt deploy --build` locally) covers every framework.
|
|
8
|
+
*
|
|
9
|
+
* Returns { framework, install, build, outputDir } where install/build are
|
|
10
|
+
* shell commands (install is null when dependencies are already there, build
|
|
11
|
+
* is null for apps that are already static files).
|
|
12
|
+
*/
|
|
13
|
+
export function detectBuild(dir, { buildCommand } = {}) {
|
|
14
|
+
if (existsSync(path.join(dir, "pubspec.yaml"))) {
|
|
15
|
+
return {
|
|
16
|
+
framework: "Flutter",
|
|
17
|
+
install: null, // `flutter build` fetches packages itself
|
|
18
|
+
build: buildCommand ?? "flutter build web --release",
|
|
19
|
+
outputDir: "build/web",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const packageJsonPath = path.join(dir, "package.json");
|
|
24
|
+
if (existsSync(packageJsonPath)) {
|
|
25
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
26
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
27
|
+
const scripts = pkg.scripts ?? {};
|
|
28
|
+
const pm = packageManager(dir, pkg);
|
|
29
|
+
const install = existsSync(path.join(dir, "node_modules")) ? null : installCommand(pm, dir);
|
|
30
|
+
|
|
31
|
+
if (buildCommand) return { framework: frameworkName(deps), install, build: buildCommand, outputDir: null };
|
|
32
|
+
if (scripts["build:web"]) {
|
|
33
|
+
return { framework: frameworkName(deps), install, build: runScript(pm, "build:web"), outputDir: null };
|
|
34
|
+
}
|
|
35
|
+
if (deps.expo) {
|
|
36
|
+
return { framework: "Expo", install, build: execBin(pm, "expo export --platform web"), outputDir: "dist" };
|
|
37
|
+
}
|
|
38
|
+
if (scripts.build) {
|
|
39
|
+
return { framework: frameworkName(deps), install, build: runScript(pm, "build"), outputDir: null };
|
|
40
|
+
}
|
|
41
|
+
throw new Error(
|
|
42
|
+
'package.json has no "build" script, so flaunt can\'t tell how to build this app for the web. ' +
|
|
43
|
+
'Add one, or pass --build-command "<command>".',
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (existsSync(path.join(dir, "index.html"))) {
|
|
48
|
+
return { framework: "static site", install: null, build: buildCommand ?? null, outputDir: "." };
|
|
49
|
+
}
|
|
50
|
+
if (buildCommand) return { framework: "custom", install: null, build: buildCommand, outputDir: null };
|
|
51
|
+
|
|
52
|
+
throw new Error(
|
|
53
|
+
"No pubspec.yaml, package.json or index.html here, so flaunt can't tell how to build this app. " +
|
|
54
|
+
'Run it from your app\'s folder, or pass --build-command "<command>".',
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function frameworkName(deps) {
|
|
59
|
+
if (deps.expo) return "Expo";
|
|
60
|
+
if (deps["@ionic/angular"] || deps["@ionic/react"] || deps["@ionic/vue"]) return "Ionic";
|
|
61
|
+
if (deps["@capacitor/core"]) return "Capacitor";
|
|
62
|
+
if (deps.vite) return "Vite";
|
|
63
|
+
if (deps["react-scripts"]) return "Create React App";
|
|
64
|
+
return "JavaScript app";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** npm, pnpm, yarn or bun, from the lockfile (or package.json's "packageManager"). */
|
|
68
|
+
export function packageManager(dir, pkg = {}) {
|
|
69
|
+
if (existsSync(path.join(dir, "bun.lock")) || existsSync(path.join(dir, "bun.lockb"))) return "bun";
|
|
70
|
+
if (existsSync(path.join(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
71
|
+
if (existsSync(path.join(dir, "yarn.lock"))) return "yarn";
|
|
72
|
+
const declared = typeof pkg.packageManager === "string" ? pkg.packageManager.split("@")[0] : "";
|
|
73
|
+
return ["pnpm", "yarn", "bun"].includes(declared) ? declared : "npm";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** pnpm and yarn aren't always installed; Node's corepack can run them when they're missing. */
|
|
77
|
+
function tool(pm) {
|
|
78
|
+
if (pm === "npm" || pm === "bun") return pm;
|
|
79
|
+
return hasCommand(pm) ? pm : `corepack ${pm}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function installCommand(pm, dir) {
|
|
83
|
+
switch (pm) {
|
|
84
|
+
case "npm":
|
|
85
|
+
return existsSync(path.join(dir, "package-lock.json")) ? "npm ci" : "npm install";
|
|
86
|
+
case "pnpm":
|
|
87
|
+
return `${tool("pnpm")} install --frozen-lockfile`;
|
|
88
|
+
case "yarn":
|
|
89
|
+
return `${tool("yarn")} install`;
|
|
90
|
+
case "bun":
|
|
91
|
+
return "bun install";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function runScript(pm, script) {
|
|
96
|
+
return pm === "npm" ? `npm run ${script}` : `${tool(pm)} run ${script}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function execBin(pm, command) {
|
|
100
|
+
switch (pm) {
|
|
101
|
+
case "npm":
|
|
102
|
+
return `npx --no-install ${command}`;
|
|
103
|
+
case "pnpm":
|
|
104
|
+
return `${tool("pnpm")} exec ${command}`;
|
|
105
|
+
case "yarn":
|
|
106
|
+
return `${tool("yarn")} ${command}`;
|
|
107
|
+
case "bun":
|
|
108
|
+
return `bunx ${command}`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function hasCommand(command) {
|
|
113
|
+
return spawnSync(`${command} --version`, { shell: true, stdio: "ignore" }).status === 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Runs a shell command in `dir`, streaming its output. Throws if it fails. */
|
|
117
|
+
export function run(command, dir) {
|
|
118
|
+
const result = spawnSync(command, {
|
|
119
|
+
cwd: dir,
|
|
120
|
+
shell: true,
|
|
121
|
+
stdio: "inherit",
|
|
122
|
+
// corepack would otherwise stop to ask before downloading pnpm/yarn.
|
|
123
|
+
env: { ...process.env, COREPACK_ENABLE_DOWNLOAD_PROMPT: "0" },
|
|
124
|
+
});
|
|
125
|
+
if (result.status !== 0) {
|
|
126
|
+
throw new Error(`\`${command}\` failed${result.status === null ? "" : ` with exit code ${result.status}`}.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
package/lib/files.mjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
const IGNORED_NAMES = new Set([".git", "node_modules", ".DS_Store", "Thumbs.db", ".flaunt"]);
|
|
6
|
+
|
|
7
|
+
/** Reads every file under `root`. Paths are absolute URL paths with "/" separators, also on Windows. */
|
|
8
|
+
export async function collectFiles(root) {
|
|
9
|
+
const files = [];
|
|
10
|
+
async function walk(dir) {
|
|
11
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
12
|
+
if (IGNORED_NAMES.has(entry.name)) continue;
|
|
13
|
+
const absolutePath = path.join(dir, entry.name);
|
|
14
|
+
if (entry.isDirectory()) {
|
|
15
|
+
await walk(absolutePath);
|
|
16
|
+
} else if (entry.isFile()) {
|
|
17
|
+
files.push({
|
|
18
|
+
path: "/" + path.relative(root, absolutePath).split(path.sep).join("/"),
|
|
19
|
+
contents: await readFile(absolutePath),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
await walk(root);
|
|
25
|
+
return files.sort((a, b) => a.path.localeCompare(b.path));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Cloudflare identifies uploaded assets by a 32-hex-character hash. This is the
|
|
30
|
+
* scheme from Cloudflare's direct-upload docs: SHA-256 of the base64 contents
|
|
31
|
+
* plus the file extension, so identical bytes served with a different type
|
|
32
|
+
* are stored separately.
|
|
33
|
+
*/
|
|
34
|
+
export function assetHash(contents, filePath) {
|
|
35
|
+
const extension = path.posix.extname(filePath).slice(1);
|
|
36
|
+
return createHash("sha256").update(contents.toString("base64") + extension).digest("hex").slice(0, 32);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const CONTENT_TYPES = {
|
|
40
|
+
html: "text/html; charset=utf-8",
|
|
41
|
+
htm: "text/html; charset=utf-8",
|
|
42
|
+
css: "text/css; charset=utf-8",
|
|
43
|
+
js: "text/javascript; charset=utf-8",
|
|
44
|
+
mjs: "text/javascript; charset=utf-8",
|
|
45
|
+
cjs: "text/javascript; charset=utf-8",
|
|
46
|
+
json: "application/json; charset=utf-8",
|
|
47
|
+
map: "application/json; charset=utf-8",
|
|
48
|
+
webmanifest: "application/manifest+json; charset=utf-8",
|
|
49
|
+
txt: "text/plain; charset=utf-8",
|
|
50
|
+
md: "text/markdown; charset=utf-8",
|
|
51
|
+
csv: "text/csv; charset=utf-8",
|
|
52
|
+
xml: "application/xml; charset=utf-8",
|
|
53
|
+
svg: "image/svg+xml",
|
|
54
|
+
png: "image/png",
|
|
55
|
+
jpg: "image/jpeg",
|
|
56
|
+
jpeg: "image/jpeg",
|
|
57
|
+
gif: "image/gif",
|
|
58
|
+
webp: "image/webp",
|
|
59
|
+
avif: "image/avif",
|
|
60
|
+
ico: "image/x-icon",
|
|
61
|
+
bmp: "image/bmp",
|
|
62
|
+
woff: "font/woff",
|
|
63
|
+
woff2: "font/woff2",
|
|
64
|
+
ttf: "font/ttf",
|
|
65
|
+
otf: "font/otf",
|
|
66
|
+
// Flutter web needs application/wasm for streaming compilation of CanvasKit / skwasm.
|
|
67
|
+
wasm: "application/wasm",
|
|
68
|
+
mp3: "audio/mpeg",
|
|
69
|
+
wav: "audio/wav",
|
|
70
|
+
ogg: "audio/ogg",
|
|
71
|
+
m4a: "audio/mp4",
|
|
72
|
+
mp4: "video/mp4",
|
|
73
|
+
webm: "video/webm",
|
|
74
|
+
pdf: "application/pdf",
|
|
75
|
+
zip: "application/zip",
|
|
76
|
+
apk: "application/vnd.android.package-archive",
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Cloudflare serves each asset with the content type it was uploaded with. */
|
|
80
|
+
export function contentTypeFor(filePath) {
|
|
81
|
+
const extension = path.posix.extname(filePath).slice(1).toLowerCase();
|
|
82
|
+
return CONTENT_TYPES[extension] ?? "application/octet-stream";
|
|
83
|
+
}
|
package/lib/github.mjs
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { appendFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What flaunt needs to know when it runs inside GitHub Actions, or null
|
|
6
|
+
* elsewhere. Read from the environment GitHub sets for every job.
|
|
7
|
+
*/
|
|
8
|
+
export function actionsContext(env = process.env) {
|
|
9
|
+
if (env.GITHUB_ACTIONS !== "true") return null;
|
|
10
|
+
|
|
11
|
+
let event = {};
|
|
12
|
+
try {
|
|
13
|
+
if (env.GITHUB_EVENT_PATH) event = JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, "utf8"));
|
|
14
|
+
} catch {
|
|
15
|
+
// Without the event payload we just know less; nothing below depends on it.
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const eventName = env.GITHUB_EVENT_NAME ?? "";
|
|
19
|
+
const ref = env.GITHUB_REF ?? "";
|
|
20
|
+
const defaultBranch = event.repository?.default_branch ?? null;
|
|
21
|
+
const isBranchRun = eventName === "push" || eventName === "workflow_dispatch";
|
|
22
|
+
const repository = env.GITHUB_REPOSITORY ?? "";
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
repository, // "owner/name"
|
|
26
|
+
repoName: repository.split("/")[1] ?? "",
|
|
27
|
+
eventName,
|
|
28
|
+
ref,
|
|
29
|
+
sha: env.GITHUB_SHA ?? "",
|
|
30
|
+
defaultBranch,
|
|
31
|
+
pullRequestNumber: event.pull_request?.number ?? null,
|
|
32
|
+
/** Only runs on the default branch update the live app; PRs and other branches get previews. */
|
|
33
|
+
deploysToProduction: isBranchRun && (defaultBranch === null || ref === `refs/heads/${defaultBranch}`),
|
|
34
|
+
canRequestIdToken: Boolean(env.ACTIONS_ID_TOKEN_REQUEST_URL && env.ACTIONS_ID_TOKEN_REQUEST_TOKEN),
|
|
35
|
+
apiUrl: env.GITHUB_API_URL || "https://api.github.com",
|
|
36
|
+
runUrl: repository && env.GITHUB_RUN_ID ? `${env.GITHUB_SERVER_URL || "https://github.com"}/${repository}/actions/runs/${env.GITHUB_RUN_ID}` : null,
|
|
37
|
+
summaryFile: env.GITHUB_STEP_SUMMARY || null,
|
|
38
|
+
token: env.GITHUB_TOKEN || null,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Asks GitHub for an OIDC token naming this repository, for `audience` (the
|
|
44
|
+
* platform's URL). The platform verifies GitHub's signature on it, so no
|
|
45
|
+
* secret has to be stored in the repo. Needs `permissions: id-token: write`.
|
|
46
|
+
*/
|
|
47
|
+
export async function requestIdToken(audience, env = process.env) {
|
|
48
|
+
const url = new URL(env.ACTIONS_ID_TOKEN_REQUEST_URL);
|
|
49
|
+
url.searchParams.set("audience", audience);
|
|
50
|
+
const response = await fetch(url, { headers: { authorization: `bearer ${env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}` } });
|
|
51
|
+
if (!response.ok) throw new Error(`GitHub refused an OIDC token (HTTP ${response.status}).`);
|
|
52
|
+
const { value } = await response.json();
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Markdown describing a finished deploy, for the PR comment and the job summary. */
|
|
57
|
+
export function deployMarkdown({ project, result, qrUrl, context }) {
|
|
58
|
+
const live = result.promoted;
|
|
59
|
+
const lines = [
|
|
60
|
+
live ? `### 📱 ${project} is live` : `### 📱 Preview of ${project} is ready`,
|
|
61
|
+
"",
|
|
62
|
+
`<img src="${qrUrl}" width="132" height="132" align="right" alt="QR code for the ${live ? "app" : "preview"}">`,
|
|
63
|
+
"",
|
|
64
|
+
"| | |",
|
|
65
|
+
"|---|---|",
|
|
66
|
+
];
|
|
67
|
+
if (live) lines.push(`| **App** | ${result.productionUrl} |`);
|
|
68
|
+
lines.push(`| **This deployment** | ${result.url} |`);
|
|
69
|
+
lines.push(`| **Phone preview** | [Open the dashboard](${result.dashboardUrl}?d=${result.id}) |`);
|
|
70
|
+
if (context?.sha) lines.push(`| **Commit** | \`${context.sha.slice(0, 7)}\` |`);
|
|
71
|
+
lines.push("");
|
|
72
|
+
lines.push(
|
|
73
|
+
live
|
|
74
|
+
? "Scan the code to open it on your phone, then use **Add to Home Screen** (iOS) or **Install app** (Android)."
|
|
75
|
+
: `Scan the code to try it on your phone. The live app doesn't change until this is merged${context?.defaultBranch ? ` into \`${context.defaultBranch}\`` : ""}.`,
|
|
76
|
+
);
|
|
77
|
+
return lines.join("\n");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const commentMarker = (project) => `<!-- flaunt-your-app:${project} -->`;
|
|
81
|
+
|
|
82
|
+
/** Posts the preview link on the pull request, or updates flaunt's earlier comment there. */
|
|
83
|
+
export async function commentOnPullRequest(context, project, markdown) {
|
|
84
|
+
const headers = {
|
|
85
|
+
authorization: `Bearer ${context.token}`,
|
|
86
|
+
accept: "application/vnd.github+json",
|
|
87
|
+
"content-type": "application/json",
|
|
88
|
+
"user-agent": "flaunt-your-app",
|
|
89
|
+
};
|
|
90
|
+
const base = `${context.apiUrl}/repos/${context.repository}/issues`;
|
|
91
|
+
const body = JSON.stringify({ body: `${commentMarker(project)}\n${markdown}` });
|
|
92
|
+
|
|
93
|
+
const list = await fetch(`${base}/${context.pullRequestNumber}/comments?per_page=100`, { headers });
|
|
94
|
+
if (!list.ok) throw new Error(`listing PR comments failed (HTTP ${list.status})`);
|
|
95
|
+
const existing = (await list.json()).find((c) => c.body?.startsWith(commentMarker(project)));
|
|
96
|
+
|
|
97
|
+
const response = existing
|
|
98
|
+
? await fetch(`${base}/comments/${existing.id}`, { method: "PATCH", headers, body })
|
|
99
|
+
: await fetch(`${base}/${context.pullRequestNumber}/comments`, { method: "POST", headers, body });
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`HTTP ${response.status}${response.status === 403 ? "; add `pull-requests: write` to the workflow's permissions" : ""}`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function writeJobSummary(context, markdown) {
|
|
108
|
+
if (context.summaryFile) await appendFile(context.summaryFile, `${markdown}\n`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** "owner/name" from a GitHub remote URL (https or ssh), or null. */
|
|
112
|
+
export function githubRepo(remoteUrl) {
|
|
113
|
+
const match = remoteUrl?.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
|
|
114
|
+
return match ? `${match[1]}/${match[2]}` : null;
|
|
115
|
+
}
|
package/lib/pwa.mjs
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { crc32, deflateSync } from "node:zlib";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Makes an app installable to the home screen when its build has no web app
|
|
5
|
+
* manifest (common with `expo export --platform web`): adds a manifest and
|
|
6
|
+
* generated icons under /__flaunt/, and the matching tags to every HTML page.
|
|
7
|
+
* Apps that already ship a manifest are left exactly as they are.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const PWA_DIR = "/__flaunt";
|
|
11
|
+
const ICON_SIZES = [180, 192, 512];
|
|
12
|
+
|
|
13
|
+
const HAS_MANIFEST = /<link\b[^>]*\brel\s*=\s*["']?[^"'>]*\bmanifest\b/i;
|
|
14
|
+
const HAS_THEME_COLOR = /<meta\b[^>]*\bname\s*=\s*["']?theme-color\b/i;
|
|
15
|
+
const HAS_APPLE_ICON = /<link\b[^>]*\brel\s*=\s*["']?[^"'>]*\bapple-touch-icon\b/i;
|
|
16
|
+
const HAS_APPLE_CAPABLE = /<meta\b[^>]*\bname\s*=\s*["']?apple-mobile-web-app-capable\b/i;
|
|
17
|
+
|
|
18
|
+
/** Tag checks must ignore commented-out markup like `<!-- <link rel="manifest"> -->`. */
|
|
19
|
+
const withoutComments = (html) => html.replace(/<!--[\s\S]*?-->/g, "");
|
|
20
|
+
|
|
21
|
+
/** Returns the file list with PWA support added, and whether anything was added. */
|
|
22
|
+
export function addPwaSupport(files, project) {
|
|
23
|
+
const index = files.find((f) => f.path === "/index.html");
|
|
24
|
+
if (!index || HAS_MANIFEST.test(withoutComments(index.contents.toString("utf8")))) {
|
|
25
|
+
return { files, added: false };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const withTags = files.map((file) =>
|
|
29
|
+
/\.html?$/i.test(file.path) ? { ...file, contents: Buffer.from(injectTags(file.contents.toString("utf8"), project)) } : file,
|
|
30
|
+
);
|
|
31
|
+
const extras = [
|
|
32
|
+
{ path: `${PWA_DIR}/manifest.webmanifest`, contents: Buffer.from(webManifest(project)) },
|
|
33
|
+
...ICON_SIZES.map((size) => ({ path: `${PWA_DIR}/icon-${size}.png`, contents: iconPng(project, size) })),
|
|
34
|
+
];
|
|
35
|
+
return { files: [...withTags, ...extras], added: true };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Adds whichever install-related tags the page is missing, just before </head>. */
|
|
39
|
+
export function injectTags(html, project) {
|
|
40
|
+
const headEnd = html.search(/<\/head\s*>/i);
|
|
41
|
+
if (headEnd === -1) return html;
|
|
42
|
+
|
|
43
|
+
const markup = withoutComments(html);
|
|
44
|
+
const tags = [];
|
|
45
|
+
if (!HAS_MANIFEST.test(markup)) tags.push(`<link rel="manifest" href="${PWA_DIR}/manifest.webmanifest">`);
|
|
46
|
+
if (!HAS_THEME_COLOR.test(markup)) tags.push(`<meta name="theme-color" content="${brandColor(project).hex}">`);
|
|
47
|
+
if (!HAS_APPLE_ICON.test(markup)) tags.push(`<link rel="apple-touch-icon" href="${PWA_DIR}/icon-180.png">`);
|
|
48
|
+
if (!HAS_APPLE_CAPABLE.test(markup)) tags.push(`<meta name="apple-mobile-web-app-capable" content="yes">`);
|
|
49
|
+
return tags.length ? html.slice(0, headEnd) + tags.join("") + html.slice(headEnd) : html;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function webManifest(project) {
|
|
53
|
+
return JSON.stringify(
|
|
54
|
+
{
|
|
55
|
+
name: project,
|
|
56
|
+
short_name: project.length > 12 ? project.slice(0, 12) : project,
|
|
57
|
+
start_url: "/",
|
|
58
|
+
scope: "/",
|
|
59
|
+
display: "standalone",
|
|
60
|
+
background_color: "#ffffff",
|
|
61
|
+
theme_color: brandColor(project).hex,
|
|
62
|
+
icons: [
|
|
63
|
+
{ src: `${PWA_DIR}/icon-192.png`, sizes: "192x192", type: "image/png", purpose: "any" },
|
|
64
|
+
{ src: `${PWA_DIR}/icon-512.png`, sizes: "512x512", type: "image/png", purpose: "any" },
|
|
65
|
+
{ src: `${PWA_DIR}/icon-512.png`, sizes: "512x512", type: "image/png", purpose: "maskable" },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
null,
|
|
69
|
+
2,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A stable colour per project name. */
|
|
74
|
+
export function brandColor(project) {
|
|
75
|
+
let hash = 0;
|
|
76
|
+
for (const char of project) hash = (hash * 31 + char.charCodeAt(0)) >>> 0;
|
|
77
|
+
const rgb = hslToRgb(hash % 360, 0.62, 0.46);
|
|
78
|
+
return { rgb, hex: `#${rgb.map((c) => c.toString(16).padStart(2, "0")).join("")}` };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A full-bleed square in the project's colour with a white ring. Full-bleed so
|
|
83
|
+
* Android can also use it as a "maskable" icon.
|
|
84
|
+
*/
|
|
85
|
+
export function iconPng(project, size) {
|
|
86
|
+
const [r, g, b] = brandColor(project).rgb;
|
|
87
|
+
const center = size / 2;
|
|
88
|
+
const outer = size * 0.25;
|
|
89
|
+
const inner = size * 0.13;
|
|
90
|
+
const rowBytes = 1 + size * 3; // filter byte + RGB pixels
|
|
91
|
+
const raw = Buffer.alloc(rowBytes * size);
|
|
92
|
+
|
|
93
|
+
for (let y = 0; y < size; y++) {
|
|
94
|
+
for (let x = 0; x < size; x++) {
|
|
95
|
+
const distance = Math.hypot(x + 0.5 - center, y + 0.5 - center);
|
|
96
|
+
// Anti-aliased ring: full coverage between the radii, fading over one pixel at each edge.
|
|
97
|
+
const coverage = clamp01(outer + 0.5 - distance) * clamp01(distance - inner + 0.5);
|
|
98
|
+
const offset = y * rowBytes + 1 + x * 3;
|
|
99
|
+
raw[offset] = Math.round(r + (255 - r) * coverage);
|
|
100
|
+
raw[offset + 1] = Math.round(g + (255 - g) * coverage);
|
|
101
|
+
raw[offset + 2] = Math.round(b + (255 - b) * coverage);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const header = Buffer.alloc(13);
|
|
106
|
+
header.writeUInt32BE(size, 0);
|
|
107
|
+
header.writeUInt32BE(size, 4);
|
|
108
|
+
header[8] = 8; // bit depth
|
|
109
|
+
header[9] = 2; // colour type: truecolour RGB
|
|
110
|
+
|
|
111
|
+
return Buffer.concat([
|
|
112
|
+
Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
|
|
113
|
+
pngChunk("IHDR", header),
|
|
114
|
+
pngChunk("IDAT", deflateSync(raw)),
|
|
115
|
+
pngChunk("IEND", Buffer.alloc(0)),
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function pngChunk(type, data) {
|
|
120
|
+
const length = Buffer.alloc(4);
|
|
121
|
+
length.writeUInt32BE(data.length);
|
|
122
|
+
const typeAndData = Buffer.concat([Buffer.from(type, "ascii"), data]);
|
|
123
|
+
const crc = Buffer.alloc(4);
|
|
124
|
+
crc.writeUInt32BE(crc32(typeAndData));
|
|
125
|
+
return Buffer.concat([length, typeAndData, crc]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function clamp01(value) {
|
|
129
|
+
return Math.min(1, Math.max(0, value));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function hslToRgb(h, s, l) {
|
|
133
|
+
const k = (n) => (n + h / 30) % 12;
|
|
134
|
+
const a = s * Math.min(l, 1 - l);
|
|
135
|
+
const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
136
|
+
return [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
|
|
137
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const WORKFLOW_PATH: string;
|
|
2
|
+
export declare const DEFAULT_PLATFORM_URL: string;
|
|
3
|
+
export declare function workflowYaml(options: {
|
|
4
|
+
project: string;
|
|
5
|
+
branch?: string;
|
|
6
|
+
directory?: string;
|
|
7
|
+
platformUrl?: string;
|
|
8
|
+
}): string;
|
|
9
|
+
export declare function addWorkflowUrl(options: { repo: string; branch?: string; yaml: string }): string;
|
package/lib/workflow.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// The GitHub Actions workflow that deploys an app to Flaunt Your App on every push.
|
|
2
|
+
// Shared by `flaunt init` and the dashboard's setup page, so keep it free of Node APIs.
|
|
3
|
+
//
|
|
4
|
+
// It's the same file for every framework: `flaunt deploy --build` works out how to
|
|
5
|
+
// install and build the app. Only Flutter and Bun need their toolchain set up first,
|
|
6
|
+
// and those steps switch themselves on when the repo has a pubspec.yaml / bun.lock.
|
|
7
|
+
|
|
8
|
+
export const WORKFLOW_PATH = ".github/workflows/flaunt.yml";
|
|
9
|
+
export const DEFAULT_PLATFORM_URL = "https://www.flaunt-your-app.workers.dev";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {{ project: string, branch?: string, directory?: string, platformUrl?: string }} options
|
|
13
|
+
* directory: the app's folder inside the repo, for monorepos ("" or "." for the root).
|
|
14
|
+
*/
|
|
15
|
+
export function workflowYaml({ project, branch = "main", directory = "", platformUrl = DEFAULT_PLATFORM_URL }) {
|
|
16
|
+
const dir = directory.replace(/^\.?\/+|\/+$/g, "").replace(/^\.$/, "");
|
|
17
|
+
const inDir = (file) => (dir ? `${dir}/${file}` : file);
|
|
18
|
+
const platform = platformUrl.replace(/\/+$/, "");
|
|
19
|
+
const apiFlag = platform === DEFAULT_PLATFORM_URL ? "" : ` --api ${platform}`;
|
|
20
|
+
const workingDirectory = dir ? `\n working-directory: ${dir}` : "";
|
|
21
|
+
// In a monorepo, only run when the app (or this workflow) changes.
|
|
22
|
+
const paths = dir ? `\n paths: ["${dir}/**", "${WORKFLOW_PATH}"]` : "";
|
|
23
|
+
|
|
24
|
+
return `# Deploys ${project} to Flaunt Your App (${platform}/p/${project})
|
|
25
|
+
# push to ${branch} → updates the live app
|
|
26
|
+
# pull request → deploys a preview and comments its link and QR code on the PR
|
|
27
|
+
name: Flaunt Your App
|
|
28
|
+
|
|
29
|
+
on:
|
|
30
|
+
push:
|
|
31
|
+
branches: [${branch}]${paths}
|
|
32
|
+
pull_request:${paths}
|
|
33
|
+
workflow_dispatch:
|
|
34
|
+
|
|
35
|
+
permissions:
|
|
36
|
+
contents: read
|
|
37
|
+
id-token: write # proves to Flaunt Your App that this run comes from this repository
|
|
38
|
+
pull-requests: write # lets it comment preview links on pull requests
|
|
39
|
+
|
|
40
|
+
concurrency:
|
|
41
|
+
group: flaunt-\${{ github.ref }}
|
|
42
|
+
cancel-in-progress: true
|
|
43
|
+
|
|
44
|
+
jobs:
|
|
45
|
+
deploy:
|
|
46
|
+
# Pull requests from forks can't prove which repository they come from, so they're skipped.
|
|
47
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
timeout-minutes: 30
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v7
|
|
52
|
+
|
|
53
|
+
- uses: actions/setup-node@v7
|
|
54
|
+
with:
|
|
55
|
+
node-version: 24
|
|
56
|
+
|
|
57
|
+
- if: hashFiles('${inDir("pubspec.yaml")}') != ''
|
|
58
|
+
uses: subosito/flutter-action@v2
|
|
59
|
+
with:
|
|
60
|
+
channel: stable
|
|
61
|
+
cache: true
|
|
62
|
+
|
|
63
|
+
- if: hashFiles('${inDir("bun.lock")}', '${inDir("bun.lockb")}') != ''
|
|
64
|
+
uses: oven-sh/setup-bun@v2
|
|
65
|
+
|
|
66
|
+
- name: Build and deploy
|
|
67
|
+
run: npx --yes flaunt-your-app@latest deploy --build --name ${project}${apiFlag}${workingDirectory}
|
|
68
|
+
env:
|
|
69
|
+
GITHUB_TOKEN: \${{ github.token }}
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A link that opens GitHub's "new file" editor with the workflow filled in; one click commits it. */
|
|
74
|
+
export function addWorkflowUrl({ repo, branch = "main", yaml }) {
|
|
75
|
+
const params = new URLSearchParams({ filename: WORKFLOW_PATH, value: yaml });
|
|
76
|
+
return `https://github.com/${repo}/new/${encodeURIComponent(branch)}?${params}`;
|
|
77
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "flaunt-your-app",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "flaunt-your-app",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Host mobile apps like websites, free: deploy Expo, Flutter, Ionic and PWA web builds from GitHub or your terminal",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"expo",
|
|
7
|
+
"flutter",
|
|
8
|
+
"ionic",
|
|
9
|
+
"pwa",
|
|
10
|
+
"react-native-web",
|
|
11
|
+
"hosting",
|
|
12
|
+
"deploy",
|
|
13
|
+
"preview",
|
|
14
|
+
"github-actions"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://www.flaunt-your-app.workers.dev",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"bin": {
|
|
20
|
+
"flaunt": "bin/flaunt.mjs"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"bin",
|
|
24
|
+
"lib"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "node --test test/"
|
|
31
|
+
}
|
|
32
|
+
}
|