@inglorious/create-app 1.12.0 → 1.13.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/README.md +1 -1
- package/bin/lib/app.js +17 -3
- package/bin/lib/mobile.js +53 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ For Android and iOS builds, install Android Studio with the Android SDK and a Ja
|
|
|
99
99
|
|
|
100
100
|
Every Vite app is versioned with [Changesets](https://github.com/changesets/changesets): describe each change with `pnpm changeset`, and `pnpm release:version` raises the version in `package.json` and writes `CHANGELOG.md`. The app reads that version as `import.meta.env.VITE_APP_VERSION`.
|
|
101
101
|
|
|
102
|
-
Mobile apps also get `pnpm mobile:release`, which copies the version into the iOS and Android projects, raises the build number they share (every store upload needs a new one), builds with the values in `.env` rather than `.env.local`, and syncs. The generated README describes the whole release, upload included. With `--push` too, an `app_versions` table in Supabase holds each platform's minimum build: an older install shows nothing but an update page, so raising it makes a release mandatory.
|
|
102
|
+
Mobile apps also get `pnpm mobile:release`, which copies the version into the iOS and Android projects, raises the build number they share (every store upload needs a new one), builds with the values in `.env` rather than `.env.local`, and syncs. The generated README describes the whole release, upload included. With `--push` too, an `app_versions` table in Supabase holds each platform's minimum build: an older install shows nothing but an update page, so raising it makes a release mandatory. Mobile apps also open links to their domain in the app: with routing, `watchAppLinks` from `@inglorious/web/app-links` sends the router to the link's path, and `public/.well-known/apple-app-site-association` is generated for iOS. The generated README lists the steps left: your Team ID, the Associated Domains capability, and serving that file as JSON.
|
|
103
103
|
|
|
104
104
|
## License
|
|
105
105
|
|
package/bin/lib/app.js
CHANGED
|
@@ -69,6 +69,7 @@ export function addAppFeatures(targetDir, pkg, options) {
|
|
|
69
69
|
app.isVue = app.renderer === "vue"
|
|
70
70
|
app.hasPrompts = app.analytics || app.push
|
|
71
71
|
app.nativeUpdate = app.mobile && app.push
|
|
72
|
+
app.appLinks = app.mobile && app.routing
|
|
72
73
|
app.layout = layout(app)
|
|
73
74
|
|
|
74
75
|
const components = COMPONENTS[app.renderer]
|
|
@@ -150,8 +151,10 @@ function addDependencies(pkg, app) {
|
|
|
150
151
|
CAPACITOR_FIREBASE_VERSION
|
|
151
152
|
pkg.dependencies["@supabase/supabase-js"] = SUPABASE_VERSION
|
|
152
153
|
}
|
|
153
|
-
if (app.nativeUpdate) {
|
|
154
|
+
if (app.nativeUpdate || app.appLinks) {
|
|
154
155
|
pkg.dependencies["@capacitor/app"] = CAPACITOR_APP_VERSION
|
|
156
|
+
}
|
|
157
|
+
if (app.nativeUpdate) {
|
|
155
158
|
pkg.dependencies["@inglorious/supabase"] = "workspace:*"
|
|
156
159
|
}
|
|
157
160
|
}
|
|
@@ -210,9 +213,14 @@ function mainSource(app) {
|
|
|
210
213
|
if (app.hasPrompts) {
|
|
211
214
|
imports.push('import { renderPrompts } from "./common/prompt"')
|
|
212
215
|
}
|
|
216
|
+
if (app.nativeUpdate || app.appLinks) {
|
|
217
|
+
imports.push('import { App as NativeApp } from "@capacitor/app"')
|
|
218
|
+
}
|
|
219
|
+
if (app.appLinks) {
|
|
220
|
+
imports.push('import { watchAppLinks } from "@inglorious/web/app-links"')
|
|
221
|
+
}
|
|
213
222
|
if (app.nativeUpdate) {
|
|
214
223
|
imports.push(
|
|
215
|
-
'import { App as NativeApp } from "@capacitor/app"',
|
|
216
224
|
'import { when } from "@inglorious/web/directives/when"',
|
|
217
225
|
'import { watchNativeUpdate } from "@inglorious/web/native-update"',
|
|
218
226
|
)
|
|
@@ -245,6 +253,12 @@ supabase.auth.onAuthStateChange((_event, session) => {
|
|
|
245
253
|
})`
|
|
246
254
|
: ""
|
|
247
255
|
|
|
256
|
+
const appLinks = app.appLinks
|
|
257
|
+
? `
|
|
258
|
+
|
|
259
|
+
watchAppLinks(NativeApp, store)`
|
|
260
|
+
: ""
|
|
261
|
+
|
|
248
262
|
const nativeUpdate = app.nativeUpdate
|
|
249
263
|
? `
|
|
250
264
|
|
|
@@ -262,7 +276,7 @@ function renderApp(api${app.isTypeScript ? ": AppApi" : ""}) {
|
|
|
262
276
|
|
|
263
277
|
return `${importBlock(imports)}
|
|
264
278
|
|
|
265
|
-
${body}${session}${nativeUpdate}
|
|
279
|
+
${body}${session}${appLinks}${nativeUpdate}
|
|
266
280
|
`
|
|
267
281
|
}
|
|
268
282
|
|
package/bin/lib/mobile.js
CHANGED
|
@@ -2,7 +2,11 @@ import fs from "fs"
|
|
|
2
2
|
import { EOL } from "os"
|
|
3
3
|
import path from "path"
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
CAPACITOR_VERSION,
|
|
7
|
+
INDENTATION,
|
|
8
|
+
TYPESCRIPT_VERSION,
|
|
9
|
+
} from "./constants.js"
|
|
6
10
|
import { copyDir, toJavaIdentifier } from "./file.js"
|
|
7
11
|
|
|
8
12
|
export function addMobileSupport(targetDir, pkg, projectName, templatesRoot) {
|
|
@@ -34,6 +38,7 @@ export function addMobileSupport(targetDir, pkg, projectName, templatesRoot) {
|
|
|
34
38
|
path.join(targetDir, "capacitor.config.ts"),
|
|
35
39
|
createCapacitorConfigSource(projectName),
|
|
36
40
|
)
|
|
41
|
+
writeAppSiteAssociation(targetDir, projectName)
|
|
37
42
|
includeInNodeProject(targetDir, "capacitor.config.ts")
|
|
38
43
|
|
|
39
44
|
appendMobileSetupToReadme(targetDir)
|
|
@@ -107,6 +112,27 @@ pnpm mobile:android
|
|
|
107
112
|
pnpm mobile:ios
|
|
108
113
|
\`\`\`
|
|
109
114
|
|
|
115
|
+
### Opening links in the app
|
|
116
|
+
|
|
117
|
+
With Universal Links, a link to the app's domain opens the installed app instead of the browser, and the router goes to the link's path. The app's side is done; three steps are yours:
|
|
118
|
+
|
|
119
|
+
1. Replace \`TEAM_ID\` in \`public/.well-known/apple-app-site-association\` with your Apple Developer Team ID, and keep the bundle ID in step with \`appId\` in \`capacitor.config.ts\`. Add paths that must stay in the browser as \`{ "/": "/path*", "exclude": true }\` before the last entry.
|
|
120
|
+
2. In Xcode, select the app target, open **Signing & Capabilities**, add **Associated Domains**, and enter \`applinks:your-domain.com\`.
|
|
121
|
+
3. Serve the file as JSON, without a redirect. On Vercel, add this to \`vercel.json\`:
|
|
122
|
+
|
|
123
|
+
\`\`\`json
|
|
124
|
+
{
|
|
125
|
+
"headers": [
|
|
126
|
+
{
|
|
127
|
+
"source": "/.well-known/apple-app-site-association",
|
|
128
|
+
"headers": [{ "key": "Content-Type", "value": "application/json" }]
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
\`\`\`
|
|
133
|
+
|
|
134
|
+
Test on a device by tapping a link in Notes or Messages; typing it in Safari does not count. Apple caches the file, so a change can take a few hours to arrive. Android App Links need \`/.well-known/assetlinks.json\` with your signing certificate's SHA-256 fingerprint and an intent filter in \`AndroidManifest.xml\`; see https://developer.android.com/training/app-links.
|
|
135
|
+
|
|
110
136
|
### Releasing
|
|
111
137
|
|
|
112
138
|
The version users see comes from \`package.json\`, the same on the web, Android and iOS. The build number is shared by both native apps and must go up with every store upload.
|
|
@@ -123,7 +149,7 @@ The version users see comes from \`package.json\`, the same on the web, Android
|
|
|
123
149
|
}
|
|
124
150
|
|
|
125
151
|
export function createCapacitorConfigSource(projectName) {
|
|
126
|
-
const appId =
|
|
152
|
+
const appId = appIdOf(projectName)
|
|
127
153
|
|
|
128
154
|
return `import type { CapacitorConfig } from "@capacitor/cli"
|
|
129
155
|
|
|
@@ -137,6 +163,31 @@ export default config
|
|
|
137
163
|
`
|
|
138
164
|
}
|
|
139
165
|
|
|
166
|
+
function appIdOf(projectName) {
|
|
167
|
+
return `com.inglorious.${toJavaIdentifier(projectName)}`
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Links carrying a session token, from sign-up and password-reset emails,
|
|
171
|
+
// stay in the browser, where the sign-in flow expects them.
|
|
172
|
+
function writeAppSiteAssociation(targetDir, projectName) {
|
|
173
|
+
const association = {
|
|
174
|
+
applinks: {
|
|
175
|
+
details: [
|
|
176
|
+
{
|
|
177
|
+
appIDs: [`TEAM_ID.${appIdOf(projectName)}`],
|
|
178
|
+
components: [{ "#": "*access_token*", exclude: true }, { "/": "*" }],
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
}
|
|
183
|
+
const dir = path.join(targetDir, "public", ".well-known")
|
|
184
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
185
|
+
fs.writeFileSync(
|
|
186
|
+
path.join(dir, "apple-app-site-association"),
|
|
187
|
+
JSON.stringify(association, null, INDENTATION) + EOL,
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
140
191
|
function includeInNodeProject(targetDir, file) {
|
|
141
192
|
const tsconfigPath = path.join(targetDir, "tsconfig.node.json")
|
|
142
193
|
if (!fs.existsSync(tsconfigPath)) return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/create-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "A scaffolding tool to quickly create a new app with Inglorious Web.",
|
|
5
5
|
"author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|