launch-film 0.1.0 → 0.1.2
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/README.md +14 -12
- package/THIRD_PARTY.md +2 -2
- package/bin/launch-film.js +17 -15
- package/package.json +2 -2
- package/skills/launch-film/SKILL.md +6 -6
- package/src/brand.js +41 -24
- package/src/plan.js +2 -2
- package/src/store.js +6 -6
package/README.md
CHANGED
|
@@ -10,7 +10,9 @@ npx launch-film linear.app
|
|
|
10
10
|
|
|
11
11
|
[Watch the film](.github/assets/linear-film.mp4) (28 seconds). It was made with the command above and nothing else: no brief, no edits.
|
|
12
12
|
|
|
13
|
-
Tools that make videos with code usually start from a brief: you describe the product, its colors and the style you want. launch-film starts from the site. [
|
|
13
|
+
Tools that make videos with code usually start from a brief: you describe the product, its colors and the style you want. launch-film starts from the site. [easybrandkit](https://github.com/EminBudak/easybrandkit) reads the logo, colors, fonts and first screen in a headless browser, the page's own headline and section titles become the film's words, and a look is picked to suit the brand. You get an MP4 at 1920x1080, rendered on your machine with Chrome and ffmpeg. There is no account, no API key and nothing is uploaded.
|
|
14
|
+
|
|
15
|
+
How it was built, and what testing changed: [launch-film: Building a Product Film From a Site](https://eminbudak.com/blog/launch-film-engineering-notes/).
|
|
14
16
|
|
|
15
17
|
## Use it with your agent
|
|
16
18
|
|
|
@@ -61,12 +63,12 @@ npx launch-film render <film.json> render a film.json after editing it
|
|
|
61
63
|
npx launch-film frames <film.mp4> save stills of each clip and a contact sheet
|
|
62
64
|
npx launch-film looks | types | icons <word> | doctor
|
|
63
65
|
|
|
64
|
-
--out <dir>
|
|
65
|
-
--look <name>
|
|
66
|
-
--seconds <n>
|
|
67
|
-
--aspect 9:16
|
|
68
|
-
--brand <dir>
|
|
69
|
-
--
|
|
66
|
+
--out <dir> folder for the brand, film.json and the film (default ./launch-film-<site>)
|
|
67
|
+
--look <name> launch, aurora, gridline, pop or journal (default: picked from the brand)
|
|
68
|
+
--seconds <n> aim for 20 to 40 seconds (default 30)
|
|
69
|
+
--aspect 9:16 a vertical film (default 16:9)
|
|
70
|
+
--brand <dir> use an easybrandkit folder you already have
|
|
71
|
+
--easybrandkit <cmd> the easybrandkit to run (default: LAUNCH_FILM_EASYBRANDKIT, one on PATH, else easybrandkit with npx)
|
|
70
72
|
--no-music, --no-sfx, --jobs <n>, --keep
|
|
71
73
|
```
|
|
72
74
|
|
|
@@ -74,7 +76,7 @@ A run leaves this behind:
|
|
|
74
76
|
|
|
75
77
|
```
|
|
76
78
|
launch-film-linear.app/
|
|
77
|
-
brand/
|
|
79
|
+
brand/ easybrandkit's kit: logos, colors, fonts, first screen
|
|
78
80
|
words.json the words read from the page
|
|
79
81
|
film.json the plan, which you can edit and render again
|
|
80
82
|
film.mp4 the film
|
|
@@ -83,7 +85,7 @@ launch-film-linear.app/
|
|
|
83
85
|
|
|
84
86
|
## How it works
|
|
85
87
|
|
|
86
|
-
1. **Brand.**
|
|
88
|
+
1. **Brand.** easybrandkit opens the site in headless Chrome and saves its logos cut on their own background, its button, heading and surface colors, its font families and its first screen at 2x. Given an App Store or Google Play listing, it saves the app's icon, screenshots and rating, and reads the site the listing names.
|
|
87
89
|
2. **Words.** The page's title, description, headline and section titles are read, with the line under each section title. Every word in the film comes from there.
|
|
88
90
|
3. **Plan.** A first film is planned without a brief: the name and its promise, the real screen in a browser window, the page's own sentence as a headline, three sections as feature cards, a number the page states (or an app's store rating), the app's store screenshots, and the logo close with the site's address. It is written to `film.json`.
|
|
89
91
|
4. **Render.** Each clip is an HTML page with one paused timeline. A virtual clock steps it frame by frame in headless Chrome, so every frame is drawn for its time however long drawing takes, and the frames go to ffmpeg. Two clips render at a time.
|
|
@@ -114,7 +116,7 @@ launch-film-linear.app/
|
|
|
114
116
|
| `shots` | two or three store screenshots side by side, coming in from depth |
|
|
115
117
|
| `phone` | a phone's screen capture in a drawn phone |
|
|
116
118
|
| `scroll` | a tall page scrolling in a window |
|
|
117
|
-
| `logo` | the logo close, from
|
|
119
|
+
| `logo` | the logo close, from an easybrandkit logo file or an app icon |
|
|
118
120
|
|
|
119
121
|
Words between asterisks are set in the brand's accent color. A bar is one bar of the look's music, about two seconds; give `seconds` instead if you prefer.
|
|
120
122
|
|
|
@@ -133,7 +135,7 @@ Words between asterisks are set in the brand's accent color. A bar is one bar of
|
|
|
133
135
|
- Node 22 or newer
|
|
134
136
|
- Google Chrome or Chromium (set `LAUNCH_FILM_CHROME` to use another build)
|
|
135
137
|
- ffmpeg (set `LAUNCH_FILM_FFMPEG` and `LAUNCH_FILM_FFPROBE` to use another build)
|
|
136
|
-
- [
|
|
138
|
+
- [easybrandkit](https://github.com/EminBudak/easybrandkit): install it with `npm install -g easybrandkit`, or launch-film runs it with `npx -y easybrandkit` (set `LAUNCH_FILM_EASYBRANDKIT` to use a copy of your own)
|
|
137
139
|
|
|
138
140
|
Run `npx launch-film doctor` to check. It has been tested on macOS with Chrome 156 and ffmpeg 7.1.
|
|
139
141
|
|
|
@@ -141,7 +143,7 @@ Run `npx launch-film doctor` to check. It has been tested on macOS with Chrome 1
|
|
|
141
143
|
|
|
142
144
|
- The film says what the site says. A page with few section titles gives a thin first plan; edit `film.json` or let your agent write the scenes.
|
|
143
145
|
- A brand typeface that Google Fonts does not have is replaced by the look's own, and the render says which.
|
|
144
|
-
-
|
|
146
|
+
- easybrandkit needs a site that opens in a headless browser. A bot check or a login wall gets no kit, and a social profile is not a brand's site.
|
|
145
147
|
- A 30 second film takes one to three minutes to render on a laptop.
|
|
146
148
|
- The music is simple by design. To use your own track: `ffmpeg -i film.mp4 -i track.mp3 -map 0:v -map 1:a -c:v copy -shortest out.mp4`.
|
|
147
149
|
|
package/THIRD_PARTY.md
CHANGED
|
@@ -41,9 +41,9 @@ No font files are in this package. When a film renders, its typefaces are downlo
|
|
|
41
41
|
|
|
42
42
|
They are embedded in the pages that are rendered, and reach the film only as pixels.
|
|
43
43
|
|
|
44
|
-
###
|
|
44
|
+
### easybrandkit
|
|
45
45
|
|
|
46
|
-
`launch-film <url>` and `launch-film plan <url>` run [
|
|
46
|
+
`launch-film <url>` and `launch-film plan <url>` run [easybrandkit](https://github.com/EminBudak/easybrandkit) (MIT, by the same author) to read the site: an easybrandkit installed on PATH (`npm install -g easybrandkit`), or else `npx -y easybrandkit`, and `npx -y github:EminBudak/easybrandkit` when npm cannot give it. `LAUNCH_FILM_EASYBRANDKIT` names another command.
|
|
47
47
|
|
|
48
48
|
## Used from your machine, not shipped
|
|
49
49
|
|
package/bin/launch-film.js
CHANGED
|
@@ -20,12 +20,15 @@ Usage:
|
|
|
20
20
|
Options:
|
|
21
21
|
--out <dir> Folder for the brand, film.json and the film
|
|
22
22
|
(default: ./launch-film-<site>).
|
|
23
|
-
--brand <path> Use a
|
|
23
|
+
--brand <path> Use a kit you already have: an easybrandkit folder
|
|
24
|
+
or its brand.json.
|
|
24
25
|
--words <file> Use a words.json you already have instead of reading
|
|
25
26
|
the page again.
|
|
26
|
-
--
|
|
27
|
-
scripts/
|
|
28
|
-
|
|
27
|
+
--easybrandkit <cmd> The easybrandkit to run: a command, or the path of
|
|
28
|
+
its scripts/easybrandkit.js (default:
|
|
29
|
+
LAUNCH_FILM_EASYBRANDKIT, an easybrandkit on PATH,
|
|
30
|
+
else easybrandkit with npx).
|
|
31
|
+
Install it with npm install -g easybrandkit.
|
|
29
32
|
--look <name> launch, aurora, gridline, pop or journal (default: picked
|
|
30
33
|
from the brand).
|
|
31
34
|
--seconds <n> Aim for this length, 20-40 (default 30).
|
|
@@ -73,7 +76,7 @@ function normaliseUrl(raw) {
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
async function makePlan(url, flags) {
|
|
76
|
-
const {
|
|
79
|
+
const { runEasybrandkit, readBrand } = require("../src/brand");
|
|
77
80
|
const { readWords } = require("../src/words");
|
|
78
81
|
const { planFilm } = require("../src/plan");
|
|
79
82
|
const host = new URL(url).hostname.replace(/^www\./, "");
|
|
@@ -94,28 +97,27 @@ async function makePlan(url, flags) {
|
|
|
94
97
|
brandFile = path.join(local, path.basename(brandFile));
|
|
95
98
|
}
|
|
96
99
|
} else if (isStoreUrl(url)) {
|
|
97
|
-
//
|
|
98
|
-
// cannot
|
|
99
|
-
// read here from Apple's lookup API.
|
|
100
|
+
// easybrandkit reads a store listing and the maker's site it names. When
|
|
101
|
+
// it cannot, an App Store listing is read here from Apple's lookup API.
|
|
100
102
|
const dir = path.join(out, "brand");
|
|
101
|
-
say(`Reading the store listing with
|
|
103
|
+
say(`Reading the store listing with easybrandkit...\n`);
|
|
102
104
|
try {
|
|
103
|
-
brandFile = await
|
|
105
|
+
brandFile = await runEasybrandkit(url, dir, { command: flags.easybrandkit, log: (t) => flags.verbose && say(t) });
|
|
104
106
|
const kit = JSON.parse(fs.readFileSync(brandFile, "utf8"));
|
|
105
107
|
const listing = (kit.stores || []).find((s) => s && /appstore|googleplay/i.test(String(s.type)) && s.ok !== false);
|
|
106
|
-
if (!listing) throw new Error("
|
|
108
|
+
if (!listing) throw new Error("easybrandkit read no store listing from it");
|
|
107
109
|
kit.app = { name: listing.name || kit.name || "", by: listing.by || "", site: listing.site || "" };
|
|
108
110
|
fs.writeFileSync(brandFile, JSON.stringify(kit, null, 2) + "\n");
|
|
109
111
|
} catch (err) {
|
|
110
112
|
if (!appStoreId(url)) fail(`${err.message}`);
|
|
111
|
-
say(`
|
|
113
|
+
say(`easybrandkit could not read the listing (${err.message.split(". ")[0]}); reading it from the App Store instead.\n`);
|
|
112
114
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
113
|
-
const made = await storeBrand(url, dir, {
|
|
115
|
+
const made = await storeBrand(url, dir, { runEasybrandkit: (u, d, o) => runEasybrandkit(u, d, { ...o, command: flags.easybrandkit }), log: say });
|
|
114
116
|
brandFile = made.brandFile;
|
|
115
117
|
}
|
|
116
118
|
} else {
|
|
117
|
-
say(`Reading the brand of ${url} with
|
|
118
|
-
brandFile = await
|
|
119
|
+
say(`Reading the brand of ${url} with easybrandkit...\n`);
|
|
120
|
+
brandFile = await runEasybrandkit(url, path.join(out, "brand"), { command: flags.easybrandkit, log: (t) => flags.verbose && say(t) });
|
|
119
121
|
}
|
|
120
122
|
const brand = readBrand(brandFile);
|
|
121
123
|
// A kit made from an App Store page carries the listing's description.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "launch-film",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A launch film from a website or an App Store page: its real logo,
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A launch film from a website or an App Store page: its real logo, colors, fonts and screens, rendered locally with Chrome and ffmpeg.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Emin Budak",
|
|
7
7
|
"bin": {
|
|
@@ -21,9 +21,9 @@ If ffmpeg is missing, tell the user how to install it (`brew install ffmpeg` on
|
|
|
21
21
|
npx -y launch-film plan <url> --out film/<name>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Give the product's website, or its App Store or Google Play listing (then the listing's icon, screenshots and rating are used, with the colors, fonts and logo of the site it names). Not a social profile:
|
|
24
|
+
Give the product's website, or its App Store or Google Play listing (then the listing's icon, screenshots and rating are used, with the colors, fonts and logo of the site it names). Not a social profile: easybrandkit refuses those.
|
|
25
25
|
|
|
26
|
-
This takes 30 to 90 seconds. It runs
|
|
26
|
+
This takes 30 to 90 seconds. It runs easybrandkit (logos, colors, fonts, first screen, store screenshots) into `film/<name>/brand/`, reads the words on the page into `words.json`, and writes `film.json`: a first plan that needs no brief.
|
|
27
27
|
|
|
28
28
|
Then read, in this order:
|
|
29
29
|
|
|
@@ -31,9 +31,9 @@ Then read, in this order:
|
|
|
31
31
|
- `film/<name>/words.json`: the page's title, description, headings and the line under each heading.
|
|
32
32
|
- `film/<name>/film.json`: the plan.
|
|
33
33
|
|
|
34
|
-
If the brand looks wrong (a cookie wall, a login page, no logo), tell the user what you got and ask for the logo file or the right page. Do not go on with a wrong brand. If the site answered
|
|
34
|
+
If the brand looks wrong (a cookie wall, a login page, no logo), tell the user what you got and ask for the logo file or the right page. Do not go on with a wrong brand. If the site answered easybrandkit with a bot check, there is no kit: ask the user for the logo file and the main colors instead of guessing.
|
|
35
35
|
|
|
36
|
-
If launch-film says
|
|
36
|
+
If launch-film says easybrandkit could not be fetched, npx could not download it (no network, or a registry without it): tell the user they can install it with `npm install -g easybrandkit`, and use `--easybrandkit <path to easybrandkit's scripts/easybrandkit.js>` when they have a copy.
|
|
37
37
|
|
|
38
38
|
## 2. Pick a look
|
|
39
39
|
|
|
@@ -54,7 +54,7 @@ film.json holds `look`, `aspect` (`16:9` or `9:16`) and `clips`, played in order
|
|
|
54
54
|
| `shots` | two or three store screenshots side by side, as they are | `images` (a list) |
|
|
55
55
|
| `phone` | a phone's own screen capture in a drawn phone (not a store screenshot: many already show a phone) | `image` |
|
|
56
56
|
| `scroll` | a tall page scrolling in a window | `image` |
|
|
57
|
-
| `logo` | the logo close with the site's address | `logo` (
|
|
57
|
+
| `logo` | the logo close with the site's address | `logo` (an easybrandkit logo file) or `icon` (an app icon), `site` |
|
|
58
58
|
|
|
59
59
|
A scene object has a `type` and its words. List every type and its fields with `npx -y launch-film types`; icon names come from `npx -y launch-film icons <word>`. The ones a launch film uses most:
|
|
60
60
|
|
|
@@ -107,6 +107,6 @@ Fix what you find in film.json and render again. Then give the user the MP4's pa
|
|
|
107
107
|
## Options
|
|
108
108
|
|
|
109
109
|
- `--look <name>`, `--seconds <20-40>`, `--aspect 9:16` on `plan` or the one-go command.
|
|
110
|
-
- `--brand <folder>` uses
|
|
110
|
+
- `--brand <folder>` uses an easybrandkit folder you already have; `--words <file>` a words.json you already have.
|
|
111
111
|
- `--no-music`, `--no-sfx` on the one-go command; or set `"music": false` and `"sfx": false` in film.json.
|
|
112
112
|
- `--jobs 1` renders one clip at a time on a slow machine.
|
package/src/brand.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// ─── the brand ─────────────────────────────────────────────────────────────
|
|
3
3
|
// What a film takes from the product: its name, colours, typefaces, logo
|
|
4
|
-
// captures, screens and store pages, read from
|
|
5
|
-
// (`
|
|
6
|
-
// to it). Paths in brand.json are relative to its folder.
|
|
4
|
+
// captures, screens and store pages, read from an easybrandkit folder
|
|
5
|
+
// (`easybrandkit <url> --out <dir>` writes <dir>/brand.json and the pictures
|
|
6
|
+
// next to it). Paths in brand.json are relative to its folder.
|
|
7
7
|
|
|
8
8
|
const fs = require("fs");
|
|
9
9
|
const path = require("path");
|
|
@@ -34,28 +34,42 @@ const normHex = (v) => {
|
|
|
34
34
|
return `#${h.toUpperCase()}`;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
// The
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
function
|
|
43
|
-
const raw = String(given || process.env.
|
|
37
|
+
// The commands that may run easybrandkit, in the order they are tried: the
|
|
38
|
+
// one given (a command, or the path of easybrandkit's script), else
|
|
39
|
+
// LAUNCH_FILM_EASYBRANDKIT, else an easybrandkit installed on PATH, else
|
|
40
|
+
// easybrandkit from npm through npx, then from its GitHub repository when
|
|
41
|
+
// npm cannot give it.
|
|
42
|
+
function easybrandkitCommands(given = "") {
|
|
43
|
+
const raw = String(given || process.env.LAUNCH_FILM_EASYBRANDKIT || "").trim();
|
|
44
44
|
if (raw) {
|
|
45
|
-
if (/\.(c?js|mjs)$/i.test(raw) && fs.existsSync(raw)) return [process.execPath, raw];
|
|
46
|
-
return raw.split(" ").filter(Boolean);
|
|
45
|
+
if (/\.(c?js|mjs)$/i.test(raw) && fs.existsSync(raw)) return [[process.execPath, raw]];
|
|
46
|
+
return [raw.split(" ").filter(Boolean)];
|
|
47
47
|
}
|
|
48
|
-
const installed = onPath(process.platform === "win32" ? "
|
|
49
|
-
if (installed) return [installed];
|
|
50
|
-
|
|
48
|
+
const installed = onPath(process.platform === "win32" ? "easybrandkit.cmd" : "easybrandkit");
|
|
49
|
+
if (installed) return [[installed]];
|
|
50
|
+
const npx = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
51
|
+
return [[npx, "-y", "easybrandkit"], [npx, "-y", "github:EminBudak/easybrandkit"]];
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const HOW = "Install
|
|
54
|
+
const HOW = "Install easybrandkit (npm install -g easybrandkit), or point LAUNCH_FILM_EASYBRANDKIT (or --easybrandkit) at its scripts/easybrandkit.js, or give a kit you already have with --brand.";
|
|
54
55
|
|
|
55
|
-
// Runs
|
|
56
|
-
|
|
56
|
+
// Runs easybrandkit for a URL into a folder. Resolves the path of brand.json.
|
|
57
|
+
// The next command is tried only when npx could not fetch easybrandkit; when
|
|
58
|
+
// easybrandkit ran and failed, running it again would fail the same way.
|
|
59
|
+
async function runEasybrandkit(url, dir, { log = () => {}, command = "" } = {}) {
|
|
60
|
+
const commands = easybrandkitCommands(command);
|
|
61
|
+
for (const [i, cmd] of commands.entries()) {
|
|
62
|
+
try {
|
|
63
|
+
return await runOnce(cmd, url, dir, log);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (!err.unfetched || i === commands.length - 1) throw err;
|
|
66
|
+
log(`${err.message.split(". ")[0]}; trying ${commands[i + 1].join(" ")}\n`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function runOnce([cmd, ...pre], url, dir, log) {
|
|
57
72
|
return new Promise((resolve, reject) => {
|
|
58
|
-
const [cmd, ...pre] = brandkitCommand(command);
|
|
59
73
|
const child = spawn(cmd, [...pre, url, "--out", dir], { stdio: ["ignore", "pipe", "pipe"] });
|
|
60
74
|
let out = "";
|
|
61
75
|
child.stdout.on("data", (d) => {
|
|
@@ -66,13 +80,16 @@ function runBrandkit(url, dir, { log = () => {}, command = "" } = {}) {
|
|
|
66
80
|
out = (out + d).slice(-3000);
|
|
67
81
|
log(String(d));
|
|
68
82
|
});
|
|
69
|
-
child.on("error", (e) => reject(new Error(`
|
|
83
|
+
child.on("error", (e) => reject(new Error(`easybrandkit could not be started (${e.message}). ${HOW}`)));
|
|
70
84
|
child.on("close", (code) => {
|
|
71
85
|
if (code === 0 && fs.existsSync(path.join(dir, "brand.json"))) return resolve(path.join(dir, "brand.json"));
|
|
72
86
|
const said = out.trim().split("\n").filter(Boolean).slice(-2).join(" ");
|
|
73
|
-
|
|
87
|
+
// npm's own error lines mean npx could not fetch easybrandkit (no such
|
|
88
|
+
// package, no network) before it ran; easybrandkit never prints them.
|
|
89
|
+
const npm = /^npm (?:error|ERR!) code \S+/m.exec(out) || /^npm (?:error|ERR!) .+/m.exec(out);
|
|
90
|
+
if (npm) reject(Object.assign(new Error(`easybrandkit could not be fetched (${npm[0].trim()}). ${HOW}`), { unfetched: true }));
|
|
74
91
|
else if (/bot check/i.test(out)) reject(new Error(`${said} The brand could not be read: ask for the logo file and the main colors, or give a kit with --brand.`));
|
|
75
|
-
else reject(new Error(`
|
|
92
|
+
else reject(new Error(`easybrandkit failed (exit ${code})${said ? `: ${said}` : ""}`));
|
|
76
93
|
});
|
|
77
94
|
});
|
|
78
95
|
}
|
|
@@ -87,7 +104,7 @@ function familyName(raw) {
|
|
|
87
104
|
return /^[A-Za-z0-9 ]{2,60}$/.test(f) ? f : "";
|
|
88
105
|
}
|
|
89
106
|
|
|
90
|
-
//
|
|
107
|
+
// easybrandkit's "text" in the shape words.js gives: the page's title,
|
|
91
108
|
// description and headings in order.
|
|
92
109
|
function wordsOf(text) {
|
|
93
110
|
if (!text || typeof text !== "object") return null;
|
|
@@ -199,4 +216,4 @@ function pickLook(brand) {
|
|
|
199
216
|
return "gridline";
|
|
200
217
|
}
|
|
201
218
|
|
|
202
|
-
module.exports = {
|
|
219
|
+
module.exports = { runEasybrandkit, easybrandkitCommands, readBrand, pickLook, familyName, luminance, saturation, hue, normHex };
|
package/src/plan.js
CHANGED
|
@@ -170,7 +170,7 @@ function findNumber(texts) {
|
|
|
170
170
|
return null;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
// The headings to take copy from.
|
|
173
|
+
// The headings to take copy from. easybrandkit's are the ones the page shows,
|
|
174
174
|
// in reading order, without the navigation and footer; the page as read
|
|
175
175
|
// here adds the line under each. A store listing's feature lines (read
|
|
176
176
|
// here from its description) come first when there are any.
|
|
@@ -184,7 +184,7 @@ function mergeHeadings(kit, read) {
|
|
|
184
184
|
|
|
185
185
|
// The copy a film needs, from the page's words and the brand.
|
|
186
186
|
function copyFrom(brand, words) {
|
|
187
|
-
// The page's words as read
|
|
187
|
+
// The page's words as read; where they are thin, easybrandkit's fill in.
|
|
188
188
|
const read = words || {};
|
|
189
189
|
const kit = brand.text || {};
|
|
190
190
|
const w = {
|
package/src/store.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// An App Store address is read as the app, not as the store's website: its
|
|
4
4
|
// listing comes from Apple's public lookup API (name, maker, icon,
|
|
5
5
|
// screenshots, rating, description and the maker's own site). The maker's
|
|
6
|
-
// site, when the listing names one, is read with
|
|
6
|
+
// site, when the listing names one, is read with easybrandkit for its colors,
|
|
7
7
|
// fonts and first screen; the app's icon and screenshots are added to that
|
|
8
8
|
// kit. Without a site the kit is made from the listing alone.
|
|
9
9
|
|
|
@@ -112,17 +112,17 @@ function wordsFromListing(listing) {
|
|
|
112
112
|
return { lang: "", title: listing.name, description: paragraphs.slice(0, 2).join(" "), siteName: listing.name, ogTitle: "", ogDescription: "", headings, ctas: [], paragraphs, jsonld: [] };
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
// Makes the brand folder for an App Store address:
|
|
116
|
-
// site when there is one (
|
|
115
|
+
// Makes the brand folder for an App Store address: easybrandkit on the maker's
|
|
116
|
+
// site when there is one (runEasybrandkit), the listing's icon and screenshots
|
|
117
117
|
// added to it. Returns { brandFile, words }.
|
|
118
|
-
async function storeBrand(url, dir, {
|
|
118
|
+
async function storeBrand(url, dir, { runEasybrandkit, log = () => {} }) {
|
|
119
119
|
const listing = await appStoreListing(url);
|
|
120
120
|
fs.mkdirSync(dir, { recursive: true });
|
|
121
121
|
let brand = null;
|
|
122
122
|
if (listing.seller) {
|
|
123
|
-
log(`Reading the maker's site ${listing.seller} with
|
|
123
|
+
log(`Reading the maker's site ${listing.seller} with easybrandkit...\n`);
|
|
124
124
|
try {
|
|
125
|
-
await
|
|
125
|
+
await runEasybrandkit(listing.seller, dir, { log: () => {} });
|
|
126
126
|
brand = JSON.parse(fs.readFileSync(path.join(dir, "brand.json"), "utf8"));
|
|
127
127
|
} catch (err) {
|
|
128
128
|
log(`The maker's site could not be read (${err.message}); the film is made from the App Store listing alone.\n`);
|