refactor: mobile components (#1113)
* fix(mobile): freeze web-server assets to zips for mobile 3.23.3 Mobile 3.23.3 fetches components zips from the web-server cdn. This however causes upgraded cdn versions to fail when downloading from older mobile versions. This commit instead fetches versioned zips from an external cdn based on the static version of the app requesting the asset. Since web-server is no longer needed as a cdn, we will temporarily freeze its zip assets to those that would be requested by Mobile 3.23.3, and commit them to source control so they remain unchanged. web-server/public/components/assets will remain as-is (dynamically copied during build time of server), and not commited to source control. This cdn directory is only used by the web app. * chore: disable commitlint length rule * chore: clear git cache * refactor: use package name from package file
This commit is contained in:
@@ -121,8 +121,8 @@
|
||||
"preset": "react-native"
|
||||
},
|
||||
"componentsCdn": {
|
||||
"dev": "https://app-dev.standardnotes.com/components/zips",
|
||||
"prod": "https://app.standardnotes.com/components/zips"
|
||||
"dev": "https://cdn.jsdelivr.net/gh/standardnotes/app@",
|
||||
"prod": "https://cdn.jsdelivr.net/gh/standardnotes/app@"
|
||||
},
|
||||
"detox": {
|
||||
"configurations": {
|
||||
|
||||
@@ -18,7 +18,7 @@ import { Base64 } from 'js-base64'
|
||||
import RNFS, { DocumentDirectoryPath } from 'react-native-fs'
|
||||
import StaticServer from 'react-native-static-server'
|
||||
import { unzip } from 'react-native-zip-archive'
|
||||
import { componentsCdn } from '../../package.json'
|
||||
import { componentsCdn, version, name } from '../../package.json'
|
||||
import { MobileThemeContent } from '../Style/MobileTheme'
|
||||
import { IsDev } from './Utils'
|
||||
|
||||
@@ -74,12 +74,21 @@ export class ComponentManager extends SNComponentManager {
|
||||
void this.staticServer!.stop()
|
||||
}
|
||||
|
||||
private cdnUrlForFeature(identifier: FeatureIdentifier): string {
|
||||
const cdn = IsDev ? componentsCdn.dev : componentsCdn.prod
|
||||
const appVersion = version
|
||||
const mobilePackageName = name
|
||||
const tagPath = `${mobilePackageName}@${appVersion}`.replaceAll('@', '%40')
|
||||
const url = `${cdn}${tagPath}/packages/components/dist/zips/${identifier}.zip`
|
||||
this.log('Getting zip from cdn url', url)
|
||||
return url
|
||||
}
|
||||
|
||||
private downloadUrlForComponent(component: SNComponent): string | undefined {
|
||||
const identifier = component.identifier
|
||||
const nativeFeature = this.nativeFeatureForIdentifier(identifier)
|
||||
if (nativeFeature) {
|
||||
const cdn = IsDev ? componentsCdn.dev : componentsCdn.prod
|
||||
return `${cdn}/${identifier}.zip`
|
||||
return this.cdnUrlForFeature(identifier)
|
||||
} else {
|
||||
return component.package_info?.download_url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user