@makefully/adaptfully 3.0.0 → 3.0.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/CHANGELOG.md +16 -0
- package/README.md +10 -8
- package/lib/node/index.js +1 -1
- package/lib/node/prebuild.js +29 -2
- package/lib/node/registrations.js +14 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 3.0.2 — 2026-06-18
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Deploy script paths without a leading `/` are emitted as page-relative `script src` values (for subdirectory hosting).
|
|
10
|
+
|
|
11
|
+
## 3.0.1 — 2026-06-17
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `config.htmlInjections` — list of deploy-relative HTML paths to inject during prebuild (default: `["index.html"]`).
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Prebuild injects only configured HTML files instead of scanning every `.html` in the deploy folder.
|
|
20
|
+
|
|
5
21
|
## 3.0.0 — 2026-06-17
|
|
6
22
|
|
|
7
23
|
### Added
|
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ adaptfully deploy steam # build + platform release when credentials are pres
|
|
|
28
28
|
|
|
29
29
|
| Stage | What it does |
|
|
30
30
|
|-------|----------------|
|
|
31
|
-
| `prebuild` | Copy `deploy/` to `output/<platform>-prebuild/` and inject registrations |
|
|
31
|
+
| `prebuild` | Copy `deploy/` to `output/<platform>-prebuild/` and inject registrations into `config.htmlInjections` |
|
|
32
32
|
| `build` | Prebuild, then POST the result to Wrapfully |
|
|
33
33
|
| `deploy` | Build, then release to the target platform (Steam upload, webapp SFTP, etc. via Wrapfully when credentials are in `assets/meta/publish/`) |
|
|
34
34
|
|
|
@@ -41,7 +41,7 @@ Place `<!-- adaptfully -->` / `<!-- /adaptfully -->` markers in your HTML templa
|
|
|
41
41
|
adaptfully.register('auth', adaptfully.auth.Google);
|
|
42
42
|
|
|
43
43
|
// In-game:
|
|
44
|
-
|
|
44
|
+
const platform = adaptfully.get('auth');
|
|
45
45
|
platform.login(function (result) { /* ... */ });
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -68,7 +68,7 @@ Use plugin keys in `config.platforms.<platform>.registrations`. Custom deploy sc
|
|
|
68
68
|
"web": {
|
|
69
69
|
"registrations": {
|
|
70
70
|
"auth": "google-auth",
|
|
71
|
-
"storage": "
|
|
71
|
+
"storage": "javascript/adaptfully-bridge.js"
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"dev": {
|
|
@@ -81,7 +81,7 @@ Use plugin keys in `config.platforms.<platform>.registrations`. Custom deploy sc
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Standard plugin keys load bundled Adaptfully runtime scripts and emit an inline `adaptfully.register()` call. Path values add a `<script src="...">` tag — the script is expected to call `adaptfully.register()` itself (for example a bridge that wires `storage` and `config`).
|
|
84
|
+
Standard plugin keys load bundled Adaptfully runtime scripts and emit an inline `adaptfully.register()` call. Path values add a `<script src="...">` tag — the script is expected to call `adaptfully.register()` itself (for example a bridge that wires `storage` and `config`). Use a leading `/` for site-root URLs; omit it for paths relative to each HTML page (required when the game is hosted in a subdirectory).
|
|
85
85
|
|
|
86
86
|
Wrapfully builders (`steam`, `win`, `mac`, `android`, etc.) map to platform keys via defaults (`win` → `steam`) or an explicit `builders` array on the platform config.
|
|
87
87
|
|
|
@@ -90,6 +90,7 @@ Wrapfully builders (`steam`, `win`, `mac`, `android`, etc.) map to platform keys
|
|
|
90
90
|
```javascript
|
|
91
91
|
import {
|
|
92
92
|
prebuildPlatform,
|
|
93
|
+
resolveHtmlInjections,
|
|
93
94
|
runAdaptfullyStage,
|
|
94
95
|
buildAdaptfullyInjection,
|
|
95
96
|
injectAdaptfullyRegistrations,
|
|
@@ -103,7 +104,7 @@ import {
|
|
|
103
104
|
} from '@makefully/adaptfully';
|
|
104
105
|
```
|
|
105
106
|
|
|
106
|
-
- **`prebuildPlatform(deployFolder, platformKey, pkg)`** — copy `deploy/` to `output/<platform>-prebuild/` and inject registrations into
|
|
107
|
+
- **`prebuildPlatform(deployFolder, platformKey, pkg)`** — copy `deploy/` to `output/<platform>-prebuild/` and inject registrations into `config.htmlInjections` (default: `index.html`).
|
|
107
108
|
- **`resolveRegistrationAssets(registrations)`** — resolve runtime script paths, inline registration JS, and external script tags for a registration map (useful for Vite dev servers).
|
|
108
109
|
- **`runAdaptfullyStage('prebuild' | 'build' | 'deploy', platformKey, options)`** — run a pipeline stage programmatically.
|
|
109
110
|
|
|
@@ -139,7 +140,7 @@ npx adaptfully <prebuild|build|deploy> <platform> [server] [mode]
|
|
|
139
140
|
|
|
140
141
|
| Stage | Description |
|
|
141
142
|
|-------|-------------|
|
|
142
|
-
| `prebuild` | Copy `deploy/` → `output/<platform>-prebuild/` with registrations injected |
|
|
143
|
+
| `prebuild` | Copy `deploy/` → `output/<platform>-prebuild/` with registrations injected into `config.htmlInjections` |
|
|
143
144
|
| `build` | Prebuild, then POST to Wrapfully (no platform release) |
|
|
144
145
|
| `deploy` | Prebuild, POST to Wrapfully, then release when credentials are present |
|
|
145
146
|
|
|
@@ -283,13 +284,13 @@ Standard npm fields (`name`, `version`, `description`) are used directly. Add a
|
|
|
283
284
|
"web": {
|
|
284
285
|
"registrations": {
|
|
285
286
|
"auth": "google-auth",
|
|
286
|
-
"storage": "
|
|
287
|
+
"storage": "javascript/adaptfully-bridge.js"
|
|
287
288
|
}
|
|
288
289
|
},
|
|
289
290
|
"steam": {
|
|
290
291
|
"registrations": {
|
|
291
292
|
"auth": "steam-auth",
|
|
292
|
-
"storage": "
|
|
293
|
+
"storage": "javascript/adaptfully-bridge.js"
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
296
|
},
|
|
@@ -314,6 +315,7 @@ Standard npm fields (`name`, `version`, `description`) are used directly. Add a
|
|
|
314
315
|
| `twitterId` | Web | Twitter handle for meta tags |
|
|
315
316
|
| `steamId` | Steam | Steam app ID |
|
|
316
317
|
| `deployFolder` | Client | Neutral deploy directory staged before prebuild (default: `deploy`) |
|
|
318
|
+
| `htmlInjections` | Prebuild | Deploy-relative HTML paths to inject (default: `["index.html"]`) |
|
|
317
319
|
| `outputFolder` | Client | Prebuild output root (default: `output`) |
|
|
318
320
|
| `platforms` | Prebuild | Per-platform registration maps (see [Adaptfully runtime](#adaptfully-runtime)) |
|
|
319
321
|
| `platforms.<name>.builder` | Build/deploy | Override Wrapfully builder for a platform (default: `web` → `webapp`, others match platform key) |
|
package/lib/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { createArchive } from './archive.js';
|
|
|
2
2
|
export { loadProjectConfig, resolveServerUrl } from './config.js';
|
|
3
3
|
export { send } from './deploy.js';
|
|
4
4
|
export { adaptfullyFromCli, runAdaptfullyStage } from './pipeline.js';
|
|
5
|
-
export { prebuildPlatform, prebuildOutputDir } from './prebuild.js';
|
|
5
|
+
export { prebuildPlatform, prebuildOutputDir, resolveHtmlInjections } from './prebuild.js';
|
|
6
6
|
export { getPackageRoot, getRuntimeDir, resolveRuntimeScript } from './paths.js';
|
|
7
7
|
export {
|
|
8
8
|
STANDARD_PLUGINS,
|
package/lib/node/prebuild.js
CHANGED
|
@@ -4,10 +4,32 @@ import {
|
|
|
4
4
|
adaptfullyInjectionForPlatform,
|
|
5
5
|
injectAdaptfullyRegistrations,
|
|
6
6
|
} from './registrations.js';
|
|
7
|
-
import { copyRecursiveSync, emptyDirSync
|
|
7
|
+
import { copyRecursiveSync, emptyDirSync } from './fs-utils.js';
|
|
8
8
|
|
|
9
9
|
/** @typedef {'prebuild' | 'build' | 'deploy'} AdaptfullyStage */
|
|
10
10
|
|
|
11
|
+
const DEFAULT_HTML_INJECTIONS = ['index.html'];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {{ config?: { htmlInjections?: string[] } }} pkg
|
|
15
|
+
* @returns {string[]}
|
|
16
|
+
*/
|
|
17
|
+
export function resolveHtmlInjections(pkg) {
|
|
18
|
+
const injections = pkg.config?.htmlInjections;
|
|
19
|
+
if (injections === undefined) {
|
|
20
|
+
return DEFAULT_HTML_INJECTIONS;
|
|
21
|
+
}
|
|
22
|
+
if (!Array.isArray(injections) || injections.length === 0) {
|
|
23
|
+
throw new Error('config.htmlInjections must be a non-empty array of paths relative to the deploy folder');
|
|
24
|
+
}
|
|
25
|
+
for (const entry of injections) {
|
|
26
|
+
if (typeof entry !== 'string' || !entry.length) {
|
|
27
|
+
throw new Error('config.htmlInjections entries must be non-empty strings');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return injections;
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
/**
|
|
12
34
|
* @param {string} platformKey
|
|
13
35
|
* @param {{ config?: { platforms?: Record<string, unknown>, outputFolder?: string } }} pkg
|
|
@@ -53,7 +75,12 @@ export function prebuildPlatform(deployFolder, platformKey, pkg, options = {}) {
|
|
|
53
75
|
|
|
54
76
|
const injection = adaptfullyInjectionForPlatform(platformKey, pkg, { log });
|
|
55
77
|
if (injection) {
|
|
56
|
-
for (const
|
|
78
|
+
for (const relativePath of resolveHtmlInjections(pkg)) {
|
|
79
|
+
const htmlPath = path.join(dest, relativePath);
|
|
80
|
+
if (!fs.existsSync(htmlPath)) {
|
|
81
|
+
throw new Error(`htmlInjections file not found in deploy output: ${relativePath}`);
|
|
82
|
+
}
|
|
83
|
+
log(`adaptfully: inject ${relativePath}`);
|
|
57
84
|
injectAdaptfullyIntoHtmlFile(htmlPath, injection);
|
|
58
85
|
}
|
|
59
86
|
}
|
|
@@ -83,7 +83,7 @@ export function collectRegistrationParts(registrations) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
if (isDeployPath(value)) {
|
|
86
|
-
const src =
|
|
86
|
+
const src = normalizeDeployScriptSrc(value);
|
|
87
87
|
deployScripts.push({ key: registerKey, src });
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
@@ -130,6 +130,17 @@ function isDeployPath(value) {
|
|
|
130
130
|
return value.startsWith('/') || value.startsWith('./') || value.includes('/');
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* @param {string} value Deploy-relative script path from config
|
|
135
|
+
* @returns {string} Value for HTML script src (leading `/` = site root; otherwise page-relative)
|
|
136
|
+
*/
|
|
137
|
+
function normalizeDeployScriptSrc(value) {
|
|
138
|
+
if (value.startsWith('/')) {
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
return value.replace(/^\.\//, '');
|
|
142
|
+
}
|
|
143
|
+
|
|
133
144
|
/**
|
|
134
145
|
* @param {string} builder
|
|
135
146
|
* @param {Record<string, { builders?: string[], registrations?: RegistrationMap }>} [platforms]
|
|
@@ -178,8 +189,7 @@ export function buildAdaptfullyInjection(registrations, options = {}) {
|
|
|
178
189
|
|
|
179
190
|
for (const [registerKey, value] of Object.entries(registrations)) {
|
|
180
191
|
if (isDeployPath(value)) {
|
|
181
|
-
|
|
182
|
-
log(`adaptfully: registering ${registerKey} ← ${src}`);
|
|
192
|
+
log(`adaptfully: registering ${registerKey} ← ${normalizeDeployScriptSrc(value)}`);
|
|
183
193
|
} else {
|
|
184
194
|
log(`adaptfully: registering ${registerKey} ← ${value}`);
|
|
185
195
|
}
|
|
@@ -233,7 +243,7 @@ export function injectAdaptfullyRegistrations(html, injection) {
|
|
|
233
243
|
}
|
|
234
244
|
|
|
235
245
|
throw new Error(
|
|
236
|
-
'Cannot inject Adaptfully registrations:
|
|
246
|
+
'Cannot inject Adaptfully registrations: HTML needs '
|
|
237
247
|
+ '<!-- adaptfully -->…<!-- /adaptfully -->, <!-- scripts -->, or </head>',
|
|
238
248
|
);
|
|
239
249
|
}
|